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 OnCancel (wxCommandEvent &aEvent)
 
void OnOK (wxCommandEvent &aEvent)
 
void OnSaveAndContinue (wxCommandEvent &aEvent)
 
void OnQuit (wxCommandEvent &event)
 
void OnCloseWindow (wxCloseEvent &Event)
 
void OnSize (wxSizeEvent &SizeEvent)
 
void OnKeyDown (wxKeyEvent &aEvent)
 
void ReCreateHToolbar ()
 
virtual void ReCreateMenuBar () override
 (Re)Create the menubar for the CvPcb mainframe More...
 
void ShowChangedLanguage () override
 Function ShowChangedLanguage redraws the menus and what not in current language. 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 OnConfigurePaths (wxCommandEvent &aEvent)
 
void OnEditEquFilesList (wxCommandEvent &aEvent)
 Function OnEditEquFilesList envokes the equ files list edit dialog. More...
 
void DisplayModule (wxCommandEvent &event)
 
void OnComponentRightClick (wxMouseEvent &event)
 
void OnFootprintRightClick (wxMouseEvent &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 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 set the footprint name for all selected components in component list and selects the next component. More...
 
void SetNewPkg (const wxString &aFootprintName, int aIndex)
 Function SetNewPkg Set the footprint name for the component of position aIndex in the component list. 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...
 
bool SaveFootprintAssociation (bool doSaveSchematic)
 Function SaveFootprintAssociation saves the edits that the user has done by sending them back to eeschema via the kiway. More...
 
bool ReadNetListAndFpFiles (const std::string &aNetlist)
 Function ReadNetListAndFpFiles loads the netlist file built on the fly by Eeschema and loads footprint libraries from fp lib tables. More...
 
int ReadSchematicNetlist (const std::string &aNetlist)
 Function ReadSchematicNetlist read the netlist (.net) file built on the fly by Eeschema. More...
 
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 SendMessageToEESCHEMA ()
 Function SendMessageToEESCHEMA Send a remote command to Eeschema via a socket, Commands are $PART: "reference" put cursor on component anchor. More...
 
COMPONENTGetSelectedComponent ()
 
wxString GetSelectedFootprint ()
 
void SetStatusText (const wxString &aText, int aNumber=0) override
 
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...
 
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)
 
bool ShowPreferences (EDA_HOTKEY_CONFIG *aHotkeys, EDA_HOTKEY_CONFIG *aShowHotkeys, const wxString &aHotkeysNickname)
 
void PrintMsg (const wxString &text)
 
virtual void InstallPreferences (PAGED_DIALOG *aParent)
 Function InstallPreferences allows a Frame to load its preference panels (if any) into the preferences dialog. More...
 
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 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...
 
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 CommonSettingsChanged ()
 Function CommonSettingsChanged Notification event that some of the common (suite-wide) settings have changed. 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...
 
VTBL_ENTRY EDA_UNITS_T GetUserUnits () const
 Function GetUserUnits Allows participation in KEYWAY_PLAYER/DIALOG_SHIM userUnits inheritance. More...
 
void SetKiway (wxWindow *aDest, KIWAY *aKiway)
 Function SetKiway. More...
 

Public Attributes

wxArrayString m_ModuleLibNames
 
wxArrayString m_EquFilesNames
 
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 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

bool m_modified
 
bool m_skipComponentSelect
 
PARAM_CFG_ARRAY m_projectFileParams
 
bool m_initialized
 
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...
 

Static Protected Attributes

static constexpr int KICAD_AUI_TB_STYLE = wxAUI_TB_DEFAULT_STYLE | wxAUI_TB_PLAIN_BACKGROUND
 

Default style flags used for wxAUI toolbars

More...
 

Private Member Functions

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

wxString m_currentSearchPattern
 
NETLIST m_netlist
 
int m_filteringOptions
 
wxAuiToolBar * m_mainToolBar
 
FOOTPRINTS_LISTBOXm_footprintListBox
 
LIBRARY_LISTBOXm_libListBox
 
COMPONENTS_LISTBOXm_compListBox
 
wxTextCtrl * m_tcFilterString
 
wxStaticText * m_statusLine1
 
wxStaticText * m_statusLine2
 
wxButton * m_saveAndContinue
 

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 110 of file cvpcb_mainframe.cpp.

References BuildCmpListBox(), BuildFOOTPRINTS_LISTBOX(), BuildLIBRARY_LISTBOX(), PCAD2KICAD::Center, EDA_BASE_FRAME::config(), FRAME_MIN_SIZE_DU(), FOOTPRINT_LIST::GetInstance(), KiBitmap(), KIWAY_HOLDER::Kiway(), PCAD2KICAD::Left, LoadSettings(), EDA_BASE_FRAME::m_auimgr, m_compListBox, m_filteringOptions, m_footprintListBox, m_FootprintsList, EDA_BASE_FRAME::m_FramePos, EDA_BASE_FRAME::m_FrameSize, m_initialized, m_libListBox, m_mainToolBar, m_modified, m_saveAndContinue, m_skipComponentSelect, m_statusLine1, m_statusLine2, m_tcFilterString, OnComponentRightClick(), OnFootprintRightClick(), OnSaveAndContinue(), ReCreateHToolbar(), ReCreateMenuBar(), PCAD2KICAD::Right, wxPoint::x, and wxPoint::y.

110  :
111  KIWAY_PLAYER( aKiway, aParent, FRAME_CVPCB, _( "Assign Footprints" ), wxDefaultPosition,
113 {
114  m_compListBox = NULL;
115  m_footprintListBox = NULL;
116  m_libListBox = NULL;
117  m_mainToolBar = NULL;
118  m_modified = false;
119  m_skipComponentSelect = false;
120  m_filteringOptions = 0;
121  m_tcFilterString = NULL;
123  m_initialized = false;
124 
125  // Give an icon
126  wxIcon icon;
127  icon.CopyFromBitmap( KiBitmap( icon_cvpcb_xpm ) );
128  SetIcon( icon );
129 
130  SetAutoLayout( true );
131 
132  LoadSettings( config() );
133 
134  wxSize const frame_min( ConvertDialogToPixels( FRAME_MIN_SIZE_DU ) );
135 
136  SetSizeHints( frame_min );
137 
138  // Frame size and position
139  SetSize( m_FramePos.x, m_FramePos.y, m_FrameSize.x, m_FrameSize.y );
140 
141  ReCreateMenuBar();
143 
144  // Create list of available modules and components of the schematic
145  BuildCmpListBox();
148 
149  m_auimgr.SetManagedWindow( this );
150 
151  m_auimgr.AddPane( m_mainToolBar, EDA_PANE().HToolbar().Name( "MainToolbar" ).Top().Layer(6) );
152 
153  m_auimgr.AddPane( m_libListBox, EDA_PANE().Palette().Name( "Libraries" ).Left().Layer(1)
154  .Caption( _( "Footprint Libraries" ) )
155  .BestSize( (int) ( m_FrameSize.x * 0.20 ), m_FrameSize.y ) );
156 
157  m_auimgr.AddPane( m_compListBox, EDA_PANE().Palette().Name( "Components" ).Center().Layer(0)
158  .Caption( _( "Symbol : Footprint Assignments" ) ) );
159 
160  m_auimgr.AddPane( m_footprintListBox, EDA_PANE().Palette().Name( "Footprints" ).Right().Layer(1)
161  .Caption( _( "Filtered Footprints" ) )
162  .BestSize( (int) ( m_FrameSize.x * 0.30 ), m_FrameSize.y ) );
163 
164  // Build the bottom panel, to display 2 status texts and the buttons:
165  auto bottomPanel = new wxPanel( this );
166  auto panelSizer = new wxBoxSizer( wxVERTICAL );
167 
168  wxFlexGridSizer* fgSizerStatus = new wxFlexGridSizer( 2, 1, 0, 0 );
169  fgSizerStatus->SetFlexibleDirection( wxBOTH );
170  fgSizerStatus->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED );
171 
172  m_statusLine1 = new wxStaticText( bottomPanel, wxID_ANY, wxEmptyString );
173  fgSizerStatus->Add( m_statusLine1, 0, 0, 5 );
174 
175  m_statusLine2 = new wxStaticText( bottomPanel, wxID_ANY, wxEmptyString );
176  fgSizerStatus->Add( m_statusLine2, 0, wxBOTTOM, 3 );
177 
178  panelSizer->Add( fgSizerStatus, 1, wxEXPAND|wxLEFT, 2 );
179 
180  wxStaticLine* staticline1 = new wxStaticLine( bottomPanel );
181  panelSizer->Add( staticline1, 0, wxEXPAND, 5 );
182 
183  wxFont statusFont = wxSystemSettings::GetFont( wxSYS_DEFAULT_GUI_FONT );
184  statusFont.SetSymbolicSize( wxFONTSIZE_SMALL );
185  m_statusLine1->SetFont( statusFont );
186  m_statusLine2->SetFont( statusFont );
187 
188  // Add buttons:
189  auto buttonsSizer = new wxBoxSizer( wxHORIZONTAL );
190  auto sdbSizer = new wxStdDialogButtonSizer();
191 
192  m_saveAndContinue = new wxButton( bottomPanel, wxID_SAVE,
193  _( "Apply, Save Schematic && Continue" ) );
194  buttonsSizer->Add( m_saveAndContinue, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT, 20 );
195 
196  auto sdbSizerOK = new wxButton( bottomPanel, wxID_OK );
197  sdbSizer->AddButton( sdbSizerOK );
198  auto sdbSizerCancel = new wxButton( bottomPanel, wxID_CANCEL );
199  sdbSizer->AddButton( sdbSizerCancel );
200  sdbSizer->Realize();
201 
202  buttonsSizer->Add( sdbSizer, 0, 0, 5 );
203  panelSizer->Add( buttonsSizer, 0, wxALIGN_RIGHT|wxALL, 5 );
204 
205  bottomPanel->SetSizer( panelSizer );
206  bottomPanel->Fit();
207 
208  sdbSizerOK->SetDefault();
209 
210  m_auimgr.AddPane( bottomPanel, EDA_PANE().HToolbar().Name( "Buttons" ).Bottom().Layer(6) );
211 
212  m_auimgr.Update();
213  m_initialized = true;
214 
215  // Connect Events
216  m_saveAndContinue->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( CVPCB_MAINFRAME::OnSaveAndContinue ), NULL, this );
217  m_footprintListBox->Connect( wxEVT_RIGHT_DOWN, wxMouseEventHandler( CVPCB_MAINFRAME::OnFootprintRightClick ), NULL, this );
218  m_compListBox->Connect( wxEVT_RIGHT_DOWN, wxMouseEventHandler( CVPCB_MAINFRAME::OnComponentRightClick ), NULL, this );
219 }
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
FOOTPRINT_LIST * m_FootprintsList
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
virtual wxConfigBase * config()
Function config returns the wxConfigBase used in SaveSettings(), and is overloaded in KICAD_MANAGER_F...
wxAuiManager m_auimgr
wxSize const FRAME_MIN_SIZE_DU(350, 250)
void LoadSettings(wxConfigBase *aCfg) override
Function LoadSettings loads common frame parameters from a configuration file.
wxBitmap KiBitmap(BITMAP_DEF aBitmap)
Construct a wxBitmap from a memory record, held in a BITMAP_DEF.
Definition: bitmap.cpp:79
wxTextCtrl * m_tcFilterString
static FOOTPRINT_LIST * GetInstance(KIWAY &aKiway)
Factory function to return a FOOTPRINT_LIST via Kiway.
void OnComponentRightClick(wxMouseEvent &event)
wxAuiToolBar * m_mainToolBar
#define KICAD_DEFAULT_DRAWFRAME_STYLE
virtual void ReCreateMenuBar() override
(Re)Create the menubar for the CvPcb mainframe
void BuildFOOTPRINTS_LISTBOX()
void OnFootprintRightClick(wxMouseEvent &event)
Specialization of the wxAuiPaneInfo class for KiCad panels.
LIBRARY_LISTBOX * m_libListBox
wxStaticText * m_statusLine2
FOOTPRINTS_LISTBOX * m_footprintListBox
void OnSaveAndContinue(wxCommandEvent &aEvent)
wxButton * m_saveAndContinue
wxStaticText * m_statusLine1
CVPCB_MAINFRAME::~CVPCB_MAINFRAME ( )

Definition at line 222 of file cvpcb_mainframe.cpp.

References EDA_BASE_FRAME::m_auimgr, m_footprintListBox, m_saveAndContinue, OnFootprintRightClick(), and OnSaveAndContinue().

223 {
224  // Disconnect Events
225  m_saveAndContinue->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( CVPCB_MAINFRAME::OnSaveAndContinue ), NULL, this );
226  m_footprintListBox->Disconnect( wxEVT_RIGHT_DOWN, wxMouseEventHandler( CVPCB_MAINFRAME::OnFootprintRightClick ), NULL, this );
227 
228  m_auimgr.UnInit();
229 }
wxAuiManager m_auimgr
void OnFootprintRightClick(wxMouseEvent &event)
FOOTPRINTS_LISTBOX * m_footprintListBox
void OnSaveAndContinue(wxCommandEvent &aEvent)
wxButton * m_saveAndContinue

Member Function Documentation

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 170 of file auto_associate.cpp.

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

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

Definition at line 825 of file cvpcb_mainframe.cpp.

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

Referenced by CVPCB_MAINFRAME().

826 {
827  wxString msg;
828  COMPONENT* component;
829  wxFont guiFont = wxSystemSettings::GetFont( wxSYS_DEFAULT_GUI_FONT );
830 
831  if( m_compListBox == NULL )
832  {
834  wxDefaultPosition, wxDefaultSize );
835  m_compListBox->SetFont( wxFont( guiFont.GetPointSize(),
836  wxFONTFAMILY_MODERN,
837  wxFONTSTYLE_NORMAL,
838  wxFONTWEIGHT_NORMAL ) );
839  }
840 
842 
843  for( unsigned i = 0; i < m_netlist.GetCount(); i++ )
844  {
845  component = m_netlist.GetComponent( i );
846 
847  msg.Printf( CMP_FORMAT, m_compListBox->GetCount() + 1,
848  GetChars( component->GetReference() ),
849  GetChars( component->GetValue() ),
850  GetChars( FROM_UTF8( component->GetFPID().Format().c_str() ) ) );
851  m_compListBox->m_ComponentList.Add( msg );
852  }
853 
854  if( m_compListBox->m_ComponentList.Count() )
855  {
856  m_compListBox->SetItemCount( m_compListBox->m_ComponentList.Count() );
857  m_compListBox->SetSelection( 0, true );
858  m_compListBox->RefreshItems( 0L, m_compListBox->m_ComponentList.Count()-1 );
860  }
861 }
const LIB_ID & GetFPID() const
Definition: pcb_netlist.h: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
COMPONENTS_LISTBOX * m_compListBox
void SetSelection(int index, bool State=true)
const wxString & GetReference() const
Definition: pcb_netlist.h:151
const wxString & GetValue() const
Definition: pcb_netlist.h:153
void UpdateWidth(int aLine=-1)
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:265
#define CMP_FORMAT
Definition: cvpcb.h:30
wxArrayString m_ComponentList
Definition: listboxes.h:200
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
const char * c_str() const
Definition: utf8.h:107
size_t i
Definition: json11.cpp:597
UTF8 Format() const
Definition: lib_id.cpp:237
unsigned GetCount() const
Function GetCount.
Definition: pcb_netlist.h:256
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 auto_associate.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  if( *line == 0 )
142  continue;
143 
144  wxString wtext = FROM_UTF8( line );
145  wxString value = GetQuotedText( wtext );
146 
147  if( value.IsEmpty() )
148  continue;
149 
150  wxString footprint = GetQuotedText( wtext );
151 
152  if( footprint.IsEmpty() )
153  continue;
154 
155  value.Replace( wxT( " " ), wxT( "_" ) );
156 
157  FOOTPRINT_EQUIVALENCE* equivItem = new FOOTPRINT_EQUIVALENCE();
158  equivItem->m_ComponentValue = value;
159  equivItem->m_FootprintFPID = footprint;
160  aList.push_back( equivItem );
161  }
162 
163  fclose( file );
164  }
165 
166  return error_count;
167 }
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
wxString GetQuotedText(wxString &text)
wxArrayString m_EquFilesNames
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 &#39;non-library&#39; files.
Definition: kiface_i.h:127
char * GetLine(FILE *File, char *Line, int *LineNum, int SizeLine)
Function GetLine reads one line line from aFile.
Definition: string.cpp:290
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 FindValidPath(const wxString &aFileName) const
Definition: search_stack.h:73
void CVPCB_MAINFRAME::BuildFOOTPRINTS_LISTBOX ( )

Definition at line 805 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 ReadNetListAndFpFiles().

806 {
807  wxFont guiFont = wxSystemSettings::GetFont( wxSYS_DEFAULT_GUI_FONT );
808 
809  if( m_footprintListBox == NULL )
810  {
812  wxDefaultPosition, wxDefaultSize );
813  m_footprintListBox->SetFont( wxFont( guiFont.GetPointSize(),
814  wxFONTFAMILY_MODERN,
815  wxFONTSTYLE_NORMAL,
816  wxFONTWEIGHT_NORMAL ) );
817  }
818 
819  m_footprintListBox->SetFootprints( *m_FootprintsList, wxEmptyString, NULL,
821  DisplayStatus();
822 }
FOOTPRINT_LIST * m_FootprintsList
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...
void CVPCB_MAINFRAME::BuildLIBRARY_LISTBOX ( )

Definition at line 864 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 ReadNetListAndFpFiles().

865 {
866  wxFont guiFont = wxSystemSettings::GetFont( wxSYS_DEFAULT_GUI_FONT );
867 
868  if( m_libListBox == NULL )
869  {
871  wxDefaultPosition, wxDefaultSize );
872  m_libListBox->SetFont( wxFont( guiFont.GetPointSize(),
873  wxFONTFAMILY_MODERN,
874  wxFONTSTYLE_NORMAL,
875  wxFONTWEIGHT_NORMAL ) );
876  }
877 
878  FP_LIB_TABLE* tbl = Prj().PcbFootprintLibs( Kiway() );
879 
880  if( tbl )
881  {
882  wxArrayString libNames;
883 
884  std::vector< wxString > libNickNames = tbl->GetLogicalLibs();
885 
886  for( unsigned ii = 0; ii < libNickNames.size(); ii++ )
887  libNames.Add( libNickNames[ii] );
888 
889  m_libListBox->SetLibraryList( libNames );
890  }
891 }
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()
Return the logical library names, all of them that are pertinent to a look up done on this LIB_TABLE...
void CVPCB_MAINFRAME::ChangeFocus ( bool  aMoveRight)

Definition at line 281 of file cvpcb_mainframe.cpp.

References m_compListBox, m_footprintListBox, and m_libListBox.

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

282 {
283  wxWindow* hasFocus = wxWindow::FindFocus();
284 
285  if( aMoveRight )
286  {
287  if( hasFocus == m_libListBox )
288  m_compListBox->SetFocus();
289  else if( hasFocus == m_compListBox )
290  m_footprintListBox->SetFocus();
291  else if( hasFocus == m_footprintListBox )
292  m_libListBox->SetFocus();
293  }
294  else
295  {
296  if( hasFocus == m_libListBox )
297  m_footprintListBox->SetFocus();
298  else if( hasFocus == m_compListBox )
299  m_libListBox->SetFocus();
300  else if( hasFocus == m_footprintListBox )
301  m_compListBox->SetFocus();
302  }
303 }
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 585 of file eda_base_frame.cpp.

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

Referenced by EDA_BASE_FRAME::GetMruPath(), and PCB_EDIT_FRAME::OpenProjectFiles().

587 {
588  wxCHECK_RET( aFileName.IsOk(), wxT( "Invalid file name!" ) );
589  wxCHECK_RET( !aBackupFileExtension.IsEmpty(), wxT( "Invalid backup file extension!" ) );
590 
591  wxFileName autoSaveFileName = aFileName;
592 
593  // Check for auto save file.
594  autoSaveFileName.SetName( AUTOSAVE_PREFIX_FILENAME + aFileName.GetName() );
595 
596  wxLogTrace( traceAutoSave,
597  wxT( "Checking for auto save file " ) + autoSaveFileName.GetFullPath() );
598 
599  if( !autoSaveFileName.FileExists() )
600  return;
601 
602  wxString msg = wxString::Format( _(
603  "Well this is potentially embarrassing!\n"
604  "It appears that the last time you were editing the file\n"
605  "\"%s\"\n"
606  "it was not saved properly. Do you wish to restore the last saved edits you made?" ),
607  GetChars( aFileName.GetFullName() )
608  );
609 
610  int response = wxMessageBox( msg, Pgm().App().GetAppName(), wxYES_NO | wxICON_QUESTION, this );
611 
612  // Make a backup of the current file, delete the file, and rename the auto save file to
613  // the file name.
614  if( response == wxYES )
615  {
616  // Get the backup file name.
617  wxFileName backupFileName = aFileName;
618  backupFileName.SetExt( aBackupFileExtension );
619 
620  // If an old backup file exists, delete it. If an old copy of the file exists, rename
621  // it to the backup file name
622  if( aFileName.FileExists() )
623  {
624  // Remove the old file backup file.
625  if( backupFileName.FileExists() )
626  wxRemoveFile( backupFileName.GetFullPath() );
627 
628  // Rename the old file to the backup file name.
629  if( !wxRenameFile( aFileName.GetFullPath(), backupFileName.GetFullPath() ) )
630  {
631  msg.Printf( _( "Could not create backup file \"%s\"" ),
632  GetChars( backupFileName.GetFullPath() ) );
633  wxMessageBox( msg );
634  }
635  }
636 
637  if( !wxRenameFile( autoSaveFileName.GetFullPath(), aFileName.GetFullPath() ) )
638  {
639  wxMessageBox( _( "The auto save file could not be renamed to the board file name." ),
640  Pgm().App().GetAppName(), wxOK | wxICON_EXCLAMATION, this );
641  }
642  }
643  else
644  {
645  wxLogTrace( traceAutoSave,
646  wxT( "Removing auto save file " ) + autoSaveFileName.GetFullPath() );
647 
648  // Remove the auto save file when using the previous file as is.
649  wxRemoveFile( autoSaveFileName.GetFullPath() );
650  }
651 }
const wxChar *const traceAutoSave
Flag to enable auto save feature debug tracing.
PGM_BASE & Pgm()
The global Program "get" accessor.
Definition: kicad.cpp:66
#define AUTOSAVE_PREFIX_FILENAME
Prefix to create filenames for schematic files or other difile when auto-saved to retrieve a crash...
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 EDA_BASE_FRAME::CommonSettingsChanged ( )
virtualinherited

Function CommonSettingsChanged Notification event that some of the common (suite-wide) settings have changed.

Update menus, toolbars, local variables, etc.

Reimplemented in PCB_EDIT_FRAME, SCH_EDIT_FRAME, LIB_EDIT_FRAME, GERBVIEW_FRAME, PCB_BASE_FRAME, FOOTPRINT_EDIT_FRAME, KICAD_MANAGER_FRAME, and EDA_DRAW_FRAME.

Definition at line 244 of file eda_base_frame.cpp.

References EDA_BASE_FRAME::ReCreateMenuBar().

Referenced by EDA_DRAW_FRAME::CommonSettingsChanged(), KIWAY::CommonSettingsChanged(), and EDA_BASE_FRAME::GetMruPath().

245 {
246  if( GetMenuBar() )
247  {
248  // For icons in menus, icon scaling & hotkeys
249  ReCreateMenuBar();
250  GetMenuBar()->Refresh();
251  }
252 }
virtual void ReCreateMenuBar()
Function ReCreateMenuBar Creates recreates the menu bar.
wxConfigBase * EDA_BASE_FRAME::config ( )
protectedvirtualinherited

Function config returns the wxConfigBase used in SaveSettings(), and is overloaded in KICAD_MANAGER_FRAME.

Reimplemented in KICAD_MANAGER_FRAME.

Definition at line 360 of file eda_base_frame.cpp.

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

Referenced by CVPCB_MAINFRAME(), FOOTPRINT_VIEWER_FRAME::FOOTPRINT_VIEWER_FRAME(), GERBVIEW_FRAME::GERBVIEW_FRAME(), EDA_BASE_FRAME::isAutoSaveRequired(), SIM_PLOT_FRAME::onClose(), FOOTPRINT_WIZARD_FRAME::OnCloseWindow(), LIB_EDIT_FRAME::OnPreferencesOptions(), SCH_EDIT_FRAME::OnPreferencesOptions(), SCH_EDIT_FRAME::OpenProjectFiles(), PL_EDITOR_FRAME::PL_EDITOR_FRAME(), SIM_PLOT_FRAME::SIM_PLOT_FRAME(), and EDA_BASE_FRAME::windowClosing().

361 {
362  // KICAD_MANAGER_FRAME overrides this
363  wxConfigBase* ret = Kiface().KifaceSettings();
364  //wxASSERT( ret );
365  return ret;
366 }
KIFACE_I & Kiface()
Global KIFACE_I "get" accessor.
Definition: kicad.cpp:52
wxConfigBase * KifaceSettings() const
Definition: kiface_i.h:103
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 269 of file eda_base_frame.h.

References EDA_BASE_FRAME::m_configFrameName.

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

270  {
271  wxString baseCfgName = m_configFrameName.IsEmpty() ? GetName() : m_configFrameName;
272  return baseCfgName;
273  }
wxString m_configFrameName
prefix used in config to identify some params (frame size...) if empty, the frame name defined in CTO...
void CVPCB_MAINFRAME::CreateScreenCmp ( )

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

Definition at line 777 of file cvpcb_mainframe.cpp.

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

Referenced by DisplayModule(), FOOTPRINTS_LISTBOX::OnLeftClick(), and refreshAfterComponentSearch().

778 {
780 
781  if( !fpframe )
782  {
783  fpframe = (DISPLAY_FOOTPRINTS_FRAME*) Kiway().Player( FRAME_CVPCB_DISPLAY, true, this );
784  fpframe->Show( true );
785  }
786  else
787  {
788  if( fpframe->IsIconized() )
789  fpframe->Iconize( false );
790 
791  // The display footprint window might be buried under some other
792  // windows, so CreateScreenCmp() on an existing window would not
793  // show any difference, leaving the user confused.
794  // So we want to put it to front, second after our CVPCB_MAINFRAME.
795  // We do this by a little dance of bringing it to front then the main
796  // frame back.
797  fpframe->Raise(); // Make sure that is visible.
798  Raise(); // .. but still we want the focus.
799  }
800 
801  fpframe->InitDisplay();
802 }
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.
VTBL_ENTRY KIWAY_PLAYER * Player(FRAME_T aFrameType, bool doCreate=true, wxTopLevelWindow *aParent=NULL)
Function Player returns the KIWAY_PLAYER* given a FRAME_T.
Definition: kiway.cpp:300
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 399 of file cvpcb_mainframe.cpp.

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

400 {
401  if( IsOK( this, _( "Delete selections" ) ) )
402  {
403  m_skipComponentSelect = true;
404 
405  // Remove all selections to avoid issues when setting the fpids
407 
408  for( unsigned i = 0; i < m_netlist.GetCount(); i++ )
409  {
410  LIB_ID fpid;
411 
412  m_netlist.GetComponent( i )->SetFPID( fpid );
413  SetNewPkg( wxEmptyString );
414  }
415 
416  // Remove all selections after setting the fpids
418 
419  m_skipComponentSelect = false;
421  }
422 
423  DisplayStatus();
424 }
void SetFPID(const LIB_ID &aFPID)
Definition: pcb_netlist.h:155
COMPONENTS_LISTBOX * m_compListBox
void DeselectAll()
Removes all selection in lists which can have more than one item selected.
void SetSelection(int index, bool State=true)
void SetNewPkg(const wxString &aFootprintName)
Function SetNewPkg set the footprint name for all selected components in component list and selects t...
A logical library item identifier and consists of various portions much like a URI.
Definition: lib_id.h:51
COMPONENT * GetComponent(unsigned aIndex)
Function GetComponent returns the COMPONENT at aIndex.
Definition: pcb_netlist.h:265
size_t i
Definition: json11.cpp:597
unsigned GetCount() const
Function GetCount.
Definition: pcb_netlist.h:256
bool IsOK(wxWindow *aParent, const wxString &aMessage)
Function IsOK displays a yes/no dialog with aMessage and returns the user response.
Definition: confirm.cpp:295
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::DisplayModule ( wxCommandEvent &  event)

Definition at line 444 of file cvpcb_mainframe.cpp.

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

445 {
446  CreateScreenCmp();
447  GetFootprintViewerFrame()->RedrawScreen( wxPoint( 0, 0 ), false );
448 }
void CreateScreenCmp()
Create or Update the frame showing the current highlighted footprint and (if showed) the 3D display f...
virtual void RedrawScreen(const wxPoint &aCenterPoint, bool aWarpPointer)
Redraw the entire screen area by updating the scroll bars and mouse pointer in order to have aCenterP...
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 612 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, Format(), GetChars(), FOOTPRINTS_LISTBOX::GetCount(), FOOTPRINT_INFO::GetDescription(), COMPONENT::GetFootprintFilters(), FOOTPRINT_INFO::GetKeywords(), FOOTPRINT_LIST::GetModuleInfo(), COMPONENT::GetPinCount(), GetSelectedComponent(), GetSelectedFootprint(), LIBRARY_LISTBOX::GetSelectedLibrary(), m_filteringOptions, m_footprintListBox, m_FootprintsList, m_initialized, m_libListBox, and SetStatusText().

Referenced by BuildFOOTPRINTS_LISTBOX(), DelAssociations(), FOOTPRINTS_LISTBOX::OnLeftClick(), ReadNetListAndFpFiles(), refreshAfterComponentSearch(), SetNewPkg(), and ShowChangedLanguage().

613 {
614  if( !m_initialized )
615  return;
616 
617  wxString filters, msg;
618  COMPONENT* component = GetSelectedComponent();
619 
621  {
622  msg.Empty();
623 
624  if( component )
625  {
626  for( unsigned ii = 0; ii < component->GetFootprintFilters().GetCount(); ii++ )
627  {
628  if( msg.IsEmpty() )
629  msg += component->GetFootprintFilters()[ii];
630  else
631  msg += wxT( ", " ) + component->GetFootprintFilters()[ii];
632  }
633  }
634 
635  filters += _( "key words" ) + wxString::Format( wxT( " (%s)" ), msg );
636  }
637 
639  {
640  msg.Empty();
641 
642  if( component )
643  msg = wxString::Format( wxT( "%i" ), component->GetPinCount() );
644 
645  if( !filters.IsEmpty() )
646  filters += wxT( ", " );
647 
648  filters += _( "pin count" ) + wxString::Format( wxT( " (%s)" ), msg );
649  }
650 
652  {
654 
655  if( !filters.IsEmpty() )
656  filters += wxT( ", " );
657 
658  filters += _( "library" ) + wxString::Format( wxT( " (%s)" ), msg );
659  }
660 
662  {
663  if( !filters.IsEmpty() )
664  filters += wxT( ", " );
665 
666  filters += _( "search text" );
667  }
668 
669  if( filters.IsEmpty() )
670  msg = _( "No filtering" );
671  else
672  msg.Printf( _( "Filtered by %s" ), GetChars( filters ) );
673 
674  msg << wxT( ": " ) << m_footprintListBox->GetCount();
675 
676  SetStatusText( msg );
677 
678 
679  msg.Empty();
680  wxString footprintName = GetSelectedFootprint();
681 
682  FOOTPRINT_INFO* module = m_FootprintsList->GetModuleInfo( footprintName );
683 
684  if( module ) // can be NULL if no netlist loaded
685  {
686  msg = wxString::Format( _( "Description: %s; Key words: %s" ),
687  module->GetDescription(),
688  module->GetKeywords() );
689  }
690 
691  SetStatusText( msg, 1 );
692 }
FOOTPRINT_LIST * m_FootprintsList
FOOTPRINT_INFO * GetModuleInfo(const wxString &aFootprintId)
Get info for a module by id.
int GetPinCount() const
Definition: pcb_netlist.h:184
const wxArrayString & GetFootprintFilters() const
Definition: pcb_netlist.h:177
const wxString & GetDescription() override
wxString GetSelectedLibrary()
void SetStatusText(const wxString &aText, int aNumber=0) override
const wxString & GetKeywords()
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
wxString GetSelectedFootprint()
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
COMPONENT * GetSelectedComponent()
FOOTPRINTS_LISTBOX * m_footprintListBox
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 223 of file eda_base_frame.cpp.

Referenced by EDA_BASE_FRAME::isAutoSaveRequired(), and EDA_BASE_FRAME::onAutoSaveTimer().

224 {
225  wxCHECK_MSG( false, true, wxT( "Auto save timer function not overridden. Bad programmer!" ) );
226 }
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 738 of file hotkeys_basic.cpp.

References DEFAULT_HOTKEY_FILENAME_EXT, EDA_FILE_SELECTOR(), and Prj().

Referenced by PANEL_HOTKEYS_EDITOR::installButtons(), and EDA_BASE_FRAME::SaveProjectSettings().

740 {
741  wxString ext = DEFAULT_HOTKEY_FILENAME_EXT;
742  wxString mask = wxT( "*." ) + ext;
743 
744 #if 0
745  wxString path = wxPathOnly( Prj().GetProjectFullName() );
746 #else
747  wxString path = GetMruPath();
748 #endif
749  wxFileName fn( aDefaultShortname );
750  fn.SetExt( DEFAULT_HOTKEY_FILENAME_EXT );
751 
752  wxString filename = EDA_FILE_SELECTOR( _( "Write Hotkey Configuration File:" ),
753  path,
754  fn.GetFullPath(),
755  ext,
756  mask,
757  this,
758  wxFD_SAVE,
759  true );
760 
761  if( filename.IsEmpty() )
762  return;
763 
764  WriteHotkeyConfig( aDescList, &filename );
765  SetMruPath( wxFileName( filename ).GetPath() );
766 }
void SetMruPath(const wxString &aPath)
PROJECT & Prj()
Definition: kicad.cpp:292
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
int EDA_BASE_FRAME::GetAutoSaveInterval ( ) const
inlineinherited

Definition at line 217 of file eda_base_frame.h.

References EDA_BASE_FRAME::m_autoSaveInterval.

217 { return m_autoSaveInterval; }
int m_autoSaveInterval
The auto save interval time in seconds.
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 399 of file eda_base_frame.cpp.

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

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

401 {
402  wxFileHistory* fileHistory = aFileHistory;
403 
404  if( !fileHistory )
405  fileHistory = &Kiface().GetFileHistory();
406 
407  int baseId = fileHistory->GetBaseId();
408 
409  wxASSERT( cmdId >= baseId && cmdId < baseId + (int) fileHistory->GetCount() );
410 
411  unsigned i = cmdId - baseId;
412 
413  if( i < fileHistory->GetCount() )
414  {
415  wxString fn = fileHistory->GetHistoryFile( i );
416 
417  if( wxFileName::FileExists( fn ) )
418  return fn;
419  else
420  {
421  wxString msg = wxString::Format( _( "File \"%s\" was not found." ), fn );
422  wxMessageBox( msg );
423 
424  fileHistory->RemoveFileFromHistory( i );
425  }
426  }
427 
428  return wxEmptyString;
429 }
KIFACE_I & Kiface()
Global KIFACE_I "get" accessor.
Definition: kicad.cpp:52
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
FILE_HISTORY & GetFileHistory()
Definition: kiface_i.h:123
size_t i
Definition: json11.cpp:597
DISPLAY_FOOTPRINTS_FRAME * CVPCB_MAINFRAME::GetFootprintViewerFrame ( )
Returns
a pointer on the Footprint Viewer frame, if exists, or NULL

Definition at line 905 of file cvpcb_mainframe.cpp.

References FOOTPRINTVIEWER_FRAME_NAME.

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

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

Definition at line 506 of file eda_base_frame.cpp.

References ShowAboutDialog().

Referenced by add_search_paths(), and EDA_BASE_FRAME::IsType().

507 {
508  void ShowAboutDialog(EDA_BASE_FRAME * aParent); // See AboutDialog_main.cpp
509  ShowAboutDialog( this );
510 }
void ShowAboutDialog(EDA_BASE_FRAME *aParent)
Class EDA_BASE_FRAME is the base frame for deriving all KiCad main window classes.
void EDA_BASE_FRAME::GetKicadContribute ( wxCommandEvent &  event)
inherited

Definition at line 493 of file eda_base_frame.cpp.

References URL_GET_INVOLVED.

Referenced by add_search_paths(), and EDA_BASE_FRAME::IsType().

494 {
495  if( !wxLaunchDefaultBrowser( URL_GET_INVOLVED ) )
496  {
497  wxString msg;
498  msg.Printf( _( "Could not launch the default browser.\n"
499  "For information on how to help the KiCad project, visit %s" ),
501  wxMessageBox( msg, _( "Get involved with KiCad" ), wxOK, this );
502  }
503 }
#define URL_GET_INVOLVED
void EDA_BASE_FRAME::GetKicadHelp ( wxCommandEvent &  event)
inherited

Definition at line 432 of file eda_base_frame.cpp.

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

Referenced by add_search_paths(), and EDA_BASE_FRAME::IsType().

433 {
434  const SEARCH_STACK& search = sys_search();
435 
436  /* We have to get document for beginners,
437  * or the full specific doc
438  * if event id is wxID_INDEX, we want the document for beginners.
439  * else the specific doc file (its name is in Kiface().GetHelpFileName())
440  * The document for beginners is the same for all KiCad utilities
441  */
442  if( event.GetId() == wxID_INDEX )
443  {
444  // List of possible names for Getting Started in KiCad
445  const wxChar* names[2] = {
446  wxT( "getting_started_in_kicad" ),
447  wxT( "Getting_Started_in_KiCad" )
448  };
449 
450  wxString helpFile;
451  // Search for "getting_started_in_kicad.html" or "getting_started_in_kicad.pdf"
452  // or "Getting_Started_in_KiCad.html" or "Getting_Started_in_KiCad.pdf"
453  for( unsigned ii = 0; ii < DIM( names ); ii++ )
454  {
455  helpFile = SearchHelpFileFullPath( search, names[ii] );
456 
457  if( !helpFile.IsEmpty() )
458  break;
459  }
460 
461  if( !helpFile )
462  {
463  wxString msg = wxString::Format( _(
464  "Html or pdf help file \n\"%s\"\n or\n\"%s\" could not be found." ), names[0], names[1] );
465  wxMessageBox( msg );
466  }
467  else
468  {
469  GetAssociatedDocument( this, helpFile );
470  }
471 
472  return;
473  }
474 
475  wxString base_name = help_name();
476  wxString helpFile = SearchHelpFileFullPath( search, base_name );
477 
478  if( !helpFile )
479  {
480  wxString msg = wxString::Format( _(
481  "Help file \"%s\" could not be found." ),
482  GetChars( base_name )
483  );
484  wxMessageBox( msg );
485  }
486  else
487  {
488  GetAssociatedDocument( this, helpFile );
489  }
490 }
#define DIM(x)
of elements in an array
Definition: macros.h:98
wxString SearchHelpFileFullPath(const SEARCH_STACK &aSearchStack, const wxString &aBaseName)
Return the help file&#39;s full path.
bool GetAssociatedDocument(wxWindow *aParent, const wxString &aDocName, const wxPathList *aPaths)
Function GetAssociatedDocument open a document (file) with the suitable browser.
Definition: eda_doc.cpp:87
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...
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()
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:99
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 894 of file cvpcb_mainframe.cpp.

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

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

895 {
896  int selection = m_compListBox->GetSelection();
897 
898  if( selection >= 0 && selection < (int) m_netlist.GetCount() )
899  return m_netlist.GetComponent( selection );
900 
901  return NULL;
902 }
COMPONENTS_LISTBOX * m_compListBox
COMPONENT * GetComponent(unsigned aIndex)
Function GetComponent returns the COMPONENT at aIndex.
Definition: pcb_netlist.h:265
unsigned GetCount() const
Function GetCount.
Definition: pcb_netlist.h:256
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 913 of file cvpcb_mainframe.cpp.

References FOOTPRINTS_LISTBOX::GetSelectedFootprint(), and m_footprintListBox.

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

914 {
915  // returns the LIB_ID of the selected footprint in footprint listview
916  // or a empty string
918 }
FOOTPRINTS_LISTBOX * m_footprintListBox
EDA_UNITS_T KIWAY_HOLDER::GetUserUnits ( ) const
inherited

Function GetUserUnits Allows participation in KEYWAY_PLAYER/DIALOG_SHIM userUnits inheritance.

This would fit better in KEYWAY_PLAYER, but DIALOG_SHIMs can only use mix-ins because their primary superclass must be wxDialog.

Definition at line 40 of file kiway_holder.cpp.

References MILLIMETRES.

Referenced by DIALOG_SHIM::DIALOG_SHIM(), and KIWAY_HOLDER::Kiway().

41 {
42  return MILLIMETRES;
43 }
wxString EDA_BASE_FRAME::help_name ( )
protectedvirtualinherited

Reimplemented in KICAD_MANAGER_FRAME.

Definition at line 375 of file eda_base_frame.cpp.

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

Referenced by EDA_BASE_FRAME::GetKicadHelp(), and EDA_BASE_FRAME::isAutoSaveRequired().

376 {
377  return Kiface().GetHelpFileName();
378 }
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:121
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 709 of file hotkeys_basic.cpp.

References DEFAULT_HOTKEY_FILENAME_EXT, EDA_FILE_SELECTOR(), and ReadHotkeyConfigFile().

Referenced by PANEL_HOTKEYS_EDITOR::installButtons(), and EDA_BASE_FRAME::SaveProjectSettings().

711 {
712  wxString ext = DEFAULT_HOTKEY_FILENAME_EXT;
713  wxString mask = wxT( "*." ) + ext;
714 
715 
716  wxString path = GetMruPath();
717  wxFileName fn( aDefaultShortname );
718  fn.SetExt( DEFAULT_HOTKEY_FILENAME_EXT );
719 
720  wxString filename = EDA_FILE_SELECTOR( _( "Read Hotkey Configuration File:" ),
721  path,
722  fn.GetFullPath(),
723  ext,
724  mask,
725  this,
726  wxFD_OPEN,
727  true );
728 
729  if( filename.IsEmpty() )
730  return;
731 
732  ::ReadHotkeyConfigFile( filename, aDescList, false );
733  WriteHotkeyConfig( aDescList );
734  SetMruPath( wxFileName( filename ).GetPath() );
735 }
void SetMruPath(const wxString &aPath)
int ReadHotkeyConfigFile(const wxString &aFilename, struct EDA_HOTKEY_CONFIG *aDescList, const bool aDefaultLocation)
Function ReadHotkeyConfig Read hotkey configuration for a given app, possibly before the frame for th...
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
virtual void EDA_BASE_FRAME::InstallPreferences ( PAGED_DIALOG aParent)
inlinevirtualinherited

Function InstallPreferences allows a Frame to load its preference panels (if any) into the preferences dialog.

Parameters
aParenta paged dialog into which the preference panels should be installed

Reimplemented in PCB_EDIT_FRAME, SCH_EDIT_FRAME, LIB_EDIT_FRAME, GERBVIEW_FRAME, and FOOTPRINT_EDIT_FRAME.

Definition at line 238 of file eda_base_frame.h.

References EDA_BASE_FRAME::LoadSettings(), and EDA_BASE_FRAME::SaveSettings().

Referenced by EDA_BASE_FRAME::ShowPreferences().

238 { }
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 173 of file eda_base_frame.h.

References EDA_BASE_FRAME::config(), EDA_BASE_FRAME::doAutoSave(), EDA_BASE_FRAME::EDA_BASE_FRAME(), EDA_BASE_FRAME::help_name(), EDA_BASE_FRAME::ProcessEvent(), EDA_BASE_FRAME::SetAutoSaveInterval(), EDA_BASE_FRAME::sys_search(), and EDA_BASE_FRAME::~EDA_BASE_FRAME().

Referenced by EDA_BASE_FRAME::ProcessEvent().

173 { 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 156 of file kiway_player.cpp.

References KIWAY_PLAYER::m_modal_loop.

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

157 {
158  return !m_modal_loop;
159 }
WX_EVENT_LOOP * m_modal_loop
Definition: kiway_player.h:250
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 541 of file eda_base_frame.cpp.

References GetChars().

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

542 {
543  wxString msg;
544  wxFileName fn = aFileName;
545 
546  // Check for absence of a file path with a file name. Unfortunately KiCad
547  // uses paths relative to the current project path without the ./ part which
548  // confuses wxFileName. Making the file name path absolute may be less than
549  // elegant but it solves the problem.
550  if( fn.GetPath().IsEmpty() && fn.HasName() )
551  fn.MakeAbsolute();
552 
553  wxCHECK_MSG( fn.IsOk(), false,
554  wxT( "File name object is invalid. Bad programmer!" ) );
555  wxCHECK_MSG( !fn.GetPath().IsEmpty(), false,
556  wxT( "File name object path <" ) + fn.GetFullPath() +
557  wxT( "> is not set. Bad programmer!" ) );
558 
559  if( fn.IsDir() && !fn.IsDirWritable() )
560  {
561  msg.Printf( _( "You do not have write permissions to folder \"%s\"." ),
562  GetChars( fn.GetPath() ) );
563  }
564  else if( !fn.FileExists() && !fn.IsDirWritable() )
565  {
566  msg.Printf( _( "You do not have write permissions to save file \"%s\" to folder \"%s\"." ),
567  GetChars( fn.GetFullName() ), GetChars( fn.GetPath() ) );
568  }
569  else if( fn.FileExists() && !fn.IsFileWritable() )
570  {
571  msg.Printf( _( "You do not have write permissions to save file \"%s\"." ),
572  GetChars( fn.GetFullPath() ) );
573  }
574 
575  if( !msg.IsEmpty() )
576  {
577  wxMessageBox( msg );
578  return false;
579  }
580 
581  return true;
582 }
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::GetUserUnits(), KIWAY_HOLDER::m_kiway, KIWAY_HOLDER::Prj(), KIWAY_HOLDER::SetKiway(), and VTBL_ENTRY.

Referenced by TREEPROJECT_ITEM::Activate(), PCB_BASE_EDIT_FRAME::AddLibrary(), SCH_EDIT_FRAME::AppendSchematic(), BuildLIBRARY_LISTBOX(), DIALOG_CHOOSE_FOOTPRINT::ConstructRightPanel(), DIALOG_CHOOSE_COMPONENT::ConstructRightPanel(), PCB_BASE_FRAME::CreateAndShow3D_Frame(), CreateScreenCmp(), CVPCB_MAINFRAME(), DIALOG_RESCUE_EACH::DIALOG_RESCUE_EACH(), DIALOG_SHIM::DIALOG_SHIM(), FIELDS_GRID_TRICKS::doPopupSelection(), FIELDS_EDITOR_GRID_TRICKS::doPopupSelection(), EDIT_TOOL::editFootprintInFpEditor(), SCH_EDIT_FRAME::EditSheet(), DISPLAY_FOOTPRINTS_FRAME::Get_Module(), LIB_MANAGER::GetBufferedPart(), LIB_MANAGER::getLibraryBuffer(), FOOTPRINT_EDIT_FRAME::GetPlotSettings(), PCB_EDIT_FRAME::importFile(), SCH_EDIT_FRAME::importFile(), SCH_EDIT_FRAME::KiwayMailIn(), KIWAY_PLAYER::language_change(), KICAD_MANAGER_FRAME::language_change(), LoadFootprintFiles(), KICAD_MANAGER_FRAME::LoadProject(), TEXT_BUTTON_SYMBOL_CHOOSER::OnButtonClick(), TEXT_BUTTON_FP_CHOOSER::OnButtonClick(), KICAD_MANAGER_FRAME::OnCloseWindow(), OnEditFootprintLibraryTable(), KICAD_MANAGER_FRAME::OnEditFpLibTable(), SCH_BASE_FRAME::OnEditSymbolLibTable(), KICAD_MANAGER_FRAME::OnEditSymLibTable(), KICAD_MANAGER_FRAME::OnImportEagleFiles(), DIALOG_CHOOSE_COMPONENT::OnInitDialog(), SCH_EDIT_FRAME::OnLeftClick(), SCH_BASE_FRAME::OnOpenLibraryViewer(), KICAD_MANAGER_FRAME::OnRunPcbFpEditor(), KICAD_MANAGER_FRAME::OnRunSchLibEditor(), SCH_EDIT_FRAME::OnSimulate(), DIALOG_EDIT_ONE_FIELD::OnTextValueSelectButtonClick(), FOOTPRINT_EDIT_FRAME::OnUpdateInsertModuleInBoard(), FOOTPRINT_EDIT_FRAME::OnUpdateLoadModuleFromBoard(), SCH_EDIT_FRAME::OpenProjectFiles(), KIWAY_HOLDER::Prj(), PCB_EDIT_FRAME::Process_Config(), PCB_EDIT_FRAME::Process_Special_Functions(), FOOTPRINT_EDIT_FRAME::ProcessPreferences(), ReadNetListAndFpFiles(), FOOTPRINT_VIEWER_FRAME::ReCreateFootprintList(), FOOTPRINT_WIZARD_FRAME::ReCreateVToolbar(), LIB_EDIT_FRAME::refreshSchematic(), KICAD_MANAGER_FRAME::RunEeschema(), KICAD_MANAGER_FRAME::RunPcbNew(), SCH_EDIT_FRAME::SaveEEFile(), SaveFootprintAssociation(), FOOTPRINT_EDIT_FRAME::SaveFootprintToBoard(), SCH_BASE_FRAME::SelectComponentFromLibBrowser(), SCH_EDIT_FRAME::SendCrossProbeNetName(), PCB_EDIT_FRAME::SendCrossProbeNetName(), SendMessageToEESCHEMA(), PCB_EDIT_FRAME::SendMessageToEESCHEMA(), SCH_EDIT_FRAME::SendMessageToPCBNEW(), SCH_EDIT_FRAME::sendNetlist(), FOOTPRINT_EDIT_FRAME::SetPlotSettings(), FOOTPRINT_VIEWER_FRAME::Show3D_Frame(), FOOTPRINT_WIZARD_FRAME::Show3D_Frame(), EDA_BASE_FRAME::ShowPreferences(), SIM_PLOT_FRAME::SIM_PLOT_FRAME(), LIB_MANAGER::UpdatePart(), and DIALOG_EXCHANGE_FOOTPRINTS::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:94
void KIWAY_PLAYER::kiway_express ( KIWAY_EXPRESS aEvent)
protectedinherited

event handler, routes to derivative specific virtual KiwayMailIn()

Definition at line 177 of file kiway_player.cpp.

References KIWAY_PLAYER::KiwayMailIn().

178 {
179  // logging support
180  KiwayMailIn( aEvent ); // call the virtual, override in derived.
181 }
virtual void KiwayMailIn(KIWAY_EXPRESS &aEvent)
Function KiwayMailIn receives KIWAY_EXPRESS messages from other players.
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 947 of file cvpcb_mainframe.cpp.

References KIWAY_EXPRESS::Command(), KIWAY_EXPRESS::GetPayload(), MAIL_EESCHEMA_NETLIST, MAIL_STATUS, ReadNetListAndFpFiles(), and SetStatusText().

948 {
949  const std::string& payload = mail.GetPayload();
950 
951  //DBG(printf( "%s: %s\n", __func__, payload.c_str() );)
952 
953  switch( mail.Command() )
954  {
956  ReadNetListAndFpFiles( payload );
957  /* @todo
958  Go into SCH_EDIT_FRAME::OnOpenCvpcb( wxCommandEvent& event ) and trim GNL_ALL down.
959  */
960  break;
961 
962  case MAIL_STATUS:
963  SetStatusText( payload, 1 );
964  break;
965 
966  default:
967  ; // ignore most
968  }
969 }
void SetStatusText(const wxString &aText, int aNumber=0) override
bool ReadNetListAndFpFiles(const std::string &aNetlist)
Function ReadNetListAndFpFiles loads the netlist file built on the fly by Eeschema and loads footprin...
SCH->CVPCB netlist immediately after launching CVPCB.
Definition: mail_type.h:42
void KIWAY_PLAYER::language_change ( wxCommandEvent &  event)
protectedinherited

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

Definition at line 184 of file kiway_player.cpp.

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

185 {
186  int id = event.GetId();
187 
188  // tell all the KIWAY_PLAYERs about the language change.
189  Kiway().SetLanguage( id );
190 }
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:395
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 695 of file cvpcb_mainframe.cpp.

References FOOTPRINT_LIST::DisplayErrors(), FOOTPRINT_LIST::GetErrorCount(), LIB_TABLE::GetLogicalLibs(), KIWAY_HOLDER::Kiway(), m_FootprintsList, PROJECT::PcbFootprintLibs(), KIWAY_HOLDER::Prj(), and FOOTPRINT_LIST::ReadFootprintFiles().

Referenced by ReadNetListAndFpFiles().

696 {
697  FP_LIB_TABLE* fptbl = Prj().PcbFootprintLibs( Kiway() );
698 
699  // Check if there are footprint libraries in the footprint library table.
700  if( !fptbl || !fptbl->GetLogicalLibs().size() )
701  {
702  wxMessageBox( _( "No PCB footprint libraries are listed in the current footprint "
703  "library table." ), _( "Configuration Error" ), wxOK | wxICON_ERROR );
704  return false;
705  }
706 
707  WX_PROGRESS_REPORTER progressReporter( this, _( "Loading Footprint Libraries" ), 2 );
708 
709  m_FootprintsList->ReadFootprintFiles( fptbl, nullptr, &progressReporter );
710 
712  {
714  }
715 
716  return true;
717 }
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
FOOTPRINT_LIST * m_FootprintsList
void DisplayErrors(wxTopLevelWindow *aCaller=NULL)
PROJECT & Prj() const
Function Prj returns a reference to the PROJECT "associated with" this KIWAY.
virtual bool ReadFootprintFiles(FP_LIB_TABLE *aTable, const wxString *aNickname=nullptr, PROGRESS_REPORTER *aProgressReporter=nullptr)=0
Read all the footprints provided by the combination of aTable and aNickname.
VTBL_ENTRY FP_LIB_TABLE * PcbFootprintLibs(KIWAY &aKiway)
Return the table of footprint libraries.
unsigned GetErrorCount() const
std::vector< wxString > GetLogicalLibs()
Return the logical library names, all of them that are pertinent to a look up done on this LIB_TABLE...
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 ReadNetListAndFpFiles().

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:57
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:353
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 232 of file cvpcb_mainframe.cpp.

References FilterFootprintEntry, FRAME_DEFAULT_SIZE_DU(), EDA_BASE_FRAME::LoadSettings(), m_filteringOptions, EDA_BASE_FRAME::m_FrameSize, and FOOTPRINTS_LISTBOX::UNFILTERED_FP_LIST.

Referenced by CVPCB_MAINFRAME().

233 {
235 
236  wxSize const frame_default( ConvertDialogToPixels( FRAME_DEFAULT_SIZE_DU ) );
237 
238  if( m_FrameSize == wxDefaultSize )
239  m_FrameSize = frame_default;
240 
242 }
static const wxString FilterFootprintEntry
wxSize const FRAME_DEFAULT_SIZE_DU(450, 300)
virtual void LoadSettings(wxConfigBase *aCfg)
Function LoadSettings loads common frame parameters from a configuration file.
void EDA_BASE_FRAME::onAutoSaveTimer ( wxTimerEvent &  aEvent)
protectedinherited

Function onAutoSaveTimer handles the auto save timer event.

Definition at line 216 of file eda_base_frame.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().

217 {
218  if( !doAutoSave() )
219  m_autoSaveTimer->Start( m_autoSaveInterval * 1000, wxTIMER_ONE_SHOT );
220 }
virtual bool doAutoSave()
Function doAutoSave should be overridden by the derived class to handle the auto save feature...
wxTimer * m_autoSaveTimer
The timer used to implement the auto save feature;.
int m_autoSaveInterval
The auto save interval time in seconds.
void CVPCB_MAINFRAME::OnCancel ( wxCommandEvent &  aEvent)

Definition at line 384 of file cvpcb_mainframe.cpp.

References m_modified.

385 {
386  // Throw away modifications on a Cancel
387  m_modified = false;
388 
389  Close( false );
390 }
void CVPCB_MAINFRAME::OnCloseWindow ( wxCloseEvent &  Event)

Definition at line 259 of file cvpcb_mainframe.cpp.

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

260 {
261  if( m_modified )
262  {
263  if( !HandleUnsavedChanges( this, _( "Symbol to Footprint links have been modified.\nSave before exit?" ),
264  [&]()->bool { return SaveFootprintAssociation( false ); } ) )
265  {
266  Event.Veto();
267  return;
268  }
269  }
270 
271  // Close module display frame
273  GetFootprintViewerFrame()->Close( true );
274 
275  m_modified = false;
276 
277  Destroy();
278 }
bool HandleUnsavedChanges(wxWindow *aParent, const wxString &aMessage, const std::function< bool()> &aSaveFunction)
Function HandleUnsavedChanges displays a dialog with Save, Cancel and Discard Changes buttons...
Definition: confirm.cpp:213
DISPLAY_FOOTPRINTS_FRAME * GetFootprintViewerFrame()
bool Destroy() override
Our version of Destroy() which is virtual from wxWidgets.
bool SaveFootprintAssociation(bool doSaveSchematic)
Function SaveFootprintAssociation saves the edits that the user has done by sending them back to eesc...
void CVPCB_MAINFRAME::OnComponentRightClick ( wxMouseEvent &  event)

Definition at line 451 of file cvpcb_mainframe.cpp.

Referenced by CVPCB_MAINFRAME().

452 {
453  wxMenu menu;
454 
455  menu.Append( ID_CVPCB_CREATE_SCREENCMP, _( "View Footprint" ), _( "Show the assigned footprint in the footprint viewer" ) );
456 
457  PopupMenu( &menu );
458 }
void CVPCB_MAINFRAME::OnConfigurePaths ( wxCommandEvent &  aEvent)

Definition at line 932 of file cvpcb_mainframe.cpp.

References KIWAY_HOLDER::Prj().

933 {
934  DIALOG_CONFIGURE_PATHS dlg( this, Prj().Get3DCacheManager()->GetResolver() );
935  dlg.ShowModal();
936 }
PROJECT & Prj() const
Function Prj returns a reference to the PROJECT "associated with" this KIWAY.
void CVPCB_MAINFRAME::OnEditEquFilesList ( wxCommandEvent &  aEvent)

Function OnEditEquFilesList envokes the equ files list edit dialog.

Definition at line 62 of file dialog_config_equfiles.cpp.

63 {
64  DIALOG_CONFIG_EQUFILES dlg( this );
65 
66  dlg.ShowModal();
67 }
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 433 of file cvpcb_mainframe.cpp.

References BuildLIBRARY_LISTBOX(), KIFACE::CreateWindow(), DIALOG_PCB_LIBRARY_TABLE, dummy(), KIWAY::FACE_PCB, kiface, KIWAY::KiFACE(), KIWAY_HOLDER::Kiway(), m_FootprintsList, KIWAY_HOLDER::Prj(), and FOOTPRINT_LIST::ReadFootprintFiles().

434 {
436  kiface->CreateWindow( this, DIALOG_PCB_LIBRARY_TABLE, &Kiway() );
437 
438  wxBusyCursor dummy;
440  m_FootprintsList->ReadFootprintFiles( Prj().PcbFootprintLibs( Kiway() ) );
441 }
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
FOOTPRINT_LIST * m_FootprintsList
PROJECT & Prj() const
Function Prj returns a reference to the PROJECT "associated with" this KIWAY.
VTBL_ENTRY wxWindow * CreateWindow(wxWindow *aParent, int aClassId, KIWAY *aKIWAY, int aCtlBits=0)=0
Function CreateWindow creates a wxWindow for the current project.
virtual bool ReadFootprintFiles(FP_LIB_TABLE *aTable, const wxString *aNickname=nullptr, PROGRESS_REPORTER *aProgressReporter=nullptr)=0
Read all the footprints provided by the combination of aTable and aNickname.
pcbnew DSO
Definition: kiway.h:267
VTBL_ENTRY KIFACE * KiFACE(FACE_T aFaceId, bool doLoad=true)
Function KiFACE returns the KIFACE* given a FACE_T.
Definition: kiway.cpp:148
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...
Class KIFACE is used by a participant in the KIWAY alchemy.
Definition: kiway.h:151
return & kiface
Definition: pcbnew.cpp:219
void CVPCB_MAINFRAME::OnEnterFilteringText ( wxCommandEvent &  event)

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

Definition at line 597 of file cvpcb_mainframe.cpp.

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

598 {
599  // Called when changing the filter string in main toolbar.
600  // If the option FOOTPRINTS_LISTBOX::FILTERING_BY_NAME is set, update the list of
601  // available footprints which match the filter
602 
604 
606  return;
607 
608  OnSelectFilteringFootprint( aEvent );
609 }
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::OnFootprintRightClick ( wxMouseEvent &  event)

Definition at line 461 of file cvpcb_mainframe.cpp.

Referenced by CVPCB_MAINFRAME(), and ~CVPCB_MAINFRAME().

462 {
463  wxMenu menu;
464 
465  menu.Append( ID_CVPCB_CREATE_SCREENCMP, _( "View Footprint" ), _( "Show the current footprint in the footprint viewer" ) );
466 
467  PopupMenu( &menu );
468 }
void CVPCB_MAINFRAME::OnKeyDown ( wxKeyEvent &  aEvent)
void CVPCB_MAINFRAME::OnOK ( wxCommandEvent &  aEvent)

Definition at line 366 of file cvpcb_mainframe.cpp.

References m_modified, and SaveFootprintAssociation().

367 {
368  SaveFootprintAssociation( false );
369 
370  m_modified = false;
371 
372  Close( true );
373 }
bool SaveFootprintAssociation(bool doSaveSchematic)
Function SaveFootprintAssociation saves the edits that the user has done by sending them back to eesc...
void CVPCB_MAINFRAME::OnQuit ( wxCommandEvent &  event)

Definition at line 393 of file cvpcb_mainframe.cpp.

394 {
395  Close( false );
396 }
void CVPCB_MAINFRAME::OnSaveAndContinue ( wxCommandEvent &  aEvent)

Definition at line 376 of file cvpcb_mainframe.cpp.

References m_modified, and SaveFootprintAssociation().

Referenced by CVPCB_MAINFRAME(), and ~CVPCB_MAINFRAME().

377 {
378  SaveFootprintAssociation( true );
379 
380  m_modified = false;
381 }
bool SaveFootprintAssociation(bool doSaveSchematic)
Function SaveFootprintAssociation saves the edits that the user has done by sending them back to eesc...
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 471 of file cvpcb_mainframe.cpp.

References COMPONENT::GetFPID(), GetSelectedComponent(), LIBRARY_LISTBOX::GetSelectedLibrary(), ITEMS_LISTBOX_BASE::GetSelection(), LIB_ID::IsValid(), m_currentSearchPattern, m_filteringOptions, m_footprintListBox, m_FootprintsList, m_libListBox, m_skipComponentSelect, refreshAfterComponentSearch(), FOOTPRINTS_LISTBOX::SetFootprints(), FOOTPRINTS_LISTBOX::SetSelectedFootprint(), and FOOTPRINTS_LISTBOX::SetSelection().

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

472 {
474  return;
475 
476  wxString libraryName;
477  COMPONENT* component = GetSelectedComponent();
478  libraryName = m_libListBox->GetSelectedLibrary();
479 
480  m_footprintListBox->SetFootprints( *m_FootprintsList, libraryName, component,
482 
483  if( component && component->GetFPID().IsValid() )
485  else
487 
488  refreshAfterComponentSearch (component);
489 }
bool IsValid() const
Definition: lib_id.h:171
const LIB_ID & GetFPID() const
Definition: pcb_netlist.h:166
FOOTPRINT_LIST * m_FootprintsList
void SetSelectedFootprint(const LIB_ID &aFPID)
wxString m_currentSearchPattern
void refreshAfterComponentSearch(COMPONENT *component)
wxString GetSelectedLibrary()
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
void SetSelection(int index, bool State=true)
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...
void CVPCB_MAINFRAME::OnSelectFilteringFootprint ( wxCommandEvent &  event)

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

Definition at line 539 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(), and LIBRARY_LISTBOX::OnSelectLibrary().

540 {
541  int option = 0;
542 
543  switch( event.GetId() )
544  {
547  break;
548 
551  break;
552 
555  break;
556 
560  break;
561  }
562 
563  if( event.IsChecked() )
564  m_filteringOptions |= option;
565  else
566  m_filteringOptions &= ~option;
567 
568  wxListEvent l_event;
569  OnSelectComponent( l_event );
570 }
wxString m_currentSearchPattern
wxTextCtrl * m_tcFilterString
void OnSelectComponent(wxListEvent &event)
Function OnSelectComponent Called when clicking on a component in component list window.
void CVPCB_MAINFRAME::OnSize ( wxSizeEvent &  SizeEvent)

Definition at line 253 of file cvpcb_mainframe.cpp.

254 {
255  event.Skip();
256 }
bool CVPCB_MAINFRAME::OpenProjectFiles ( const std::vector< wxString > &  aFileSet,
int  aCtl = 0 
)
override

Definition at line 427 of file cvpcb_mainframe.cpp.

428 {
429  return true;
430 }
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 654 of file eda_base_frame.cpp.

Referenced by EDA_BASE_FRAME::GetMruPath(), 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().

655 {
656  if( evt_type != 0 )
657  {
658  wxCommandEvent evt( wxEVT_COMMAND_MENU_SELECTED );
659  evt.SetEventObject( this );
660  evt.SetId( evt_type );
661  wxPostEvent( this, evt );
662  return true;
663  }
664 
665  return false;
666 }
void EDA_BASE_FRAME::PrintMsg ( const wxString &  text)
inherited

Definition at line 381 of file eda_base_frame.cpp.

Referenced by EDA_BASE_FRAME::IsType().

382 {
383  SetStatusText( text );
384 }
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 PCB_BASE_EDIT_FRAME::AddLibrary(), LIB_MANAGER::addLibrary(), SCH_EDIT_FRAME::AppendSchematic(), PCB_EDIT_FRAME::ArchiveModulesOnBoard(), DIALOG_SYMBOL_REMAP::backupProject(), LIB_VIEW_FRAME::BestZoom(), BuildLIBRARY_LISTBOX(), DIALOG_FOOTPRINT_FP_EDITOR::Cfg3DPath(), DIALOG_FOOTPRINT_BOARD_EDITOR::Cfg3DPath(), DIALOG_EDIT_COMPONENT_IN_LIBRARY::checkAliasName(), PCB_BASE_EDIT_FRAME::CreateNewLibrary(), KICAD_MANAGER_FRAME::CreateNewProject(), DIALOG_PLOT_SCHEMATIC::createPlotFileName(), DIALOG_SYMBOL_REMAP::createProjectSymbolLibTable(), FOOTPRINT_EDIT_FRAME::DeleteModuleFromLibrary(), DIALOG_CHOOSE_COMPONENT::DIALOG_CHOOSE_COMPONENT(), DIALOG_CHOOSE_FOOTPRINT::DIALOG_CHOOSE_FOOTPRINT(), DIALOG_CONFIG_EQUFILES::DIALOG_CONFIG_EQUFILES(), DIALOG_FOOTPRINT_BOARD_EDITOR::DIALOG_FOOTPRINT_BOARD_EDITOR(), DIALOG_FOOTPRINT_FP_EDITOR::DIALOG_FOOTPRINT_FP_EDITOR(), DIALOG_PAGES_SETTINGS::DIALOG_PAGES_SETTINGS(), DIALOG_SYMBOL_REMAP::DIALOG_SYMBOL_REMAP(), LIB_VIEW_FRAME::DisplayLibInfos(), SCH_BASE_FRAME::DisplayListComponentsInLib(), PCB_EDIT_FRAME::doAutoSave(), SCH_EDIT_FRAME::EditSheet(), PCB_EDIT_FRAME::Export_IDF3(), PCB_EDIT_FRAME::Files_io_from_id(), NETLIST_DIALOG::GenNetlist(), DISPLAY_FOOTPRINTS_FRAME::Get_Module(), FOOTPRINT_VIEWER_FRAME::getCurFootprintName(), LIB_EDIT_FRAME::GetCurLib(), FOOTPRINT_VIEWER_FRAME::getCurNickname(), SCH_BASE_FRAME::GetLibAlias(), SCH_BASE_FRAME::GetLibPart(), DIALOG_SYMBOL_REMAP::getLibsNotInGlobalSymbolLibTable(), DIALOG_BOM::getPluginFileName(), KICAD_MANAGER_FRAME::GetProjectFileName(), LIB_VIEW_FRAME::getSelectedAlias(), FP_THREAD_IFACE::GetTable(), PCB_EDIT_FRAME::importFile(), SCH_EDIT_FRAME::importFile(), FOOTPRINT_EDIT_FRAME::initLibraryTree(), PCB_EDIT_FRAME::InstallNetlistFrame(), SCH_EDIT_FRAME::IsSearchCacheObsolete(), KIWAY_HOLDER::Kiway(), LIB_EDIT_FRAME::KiwayMailIn(), EDA_DRAW_FRAME::LibraryFileBrowser(), SCH_EDIT_FRAME::Load_Component(), SCH_EDIT_FRAME::LoadCmpToFootprintLinkFile(), LIB_EDIT_FRAME::LoadComponentFromCurrentLib(), LoadFootprintFiles(), DIALOG_SPICE_MODEL::loadLibrary(), LIB_EDIT_FRAME::LoadOneSymbol(), KICAD_MANAGER_FRAME::LoadProject(), LoadProjectFile(), SCH_EDIT_FRAME::LoadProjectFile(), PCB_EDIT_FRAME::LoadProjectSettings(), DIALOG_DRC_CONTROL::makeValidFileNameReport(), DIALOG_FOOTPRINT_FP_EDITOR::On3DModelCellChanged(), DIALOG_FOOTPRINT_BOARD_EDITOR::On3DModelCellChanged(), FOOTPRINT_VIEWER_FRAME::OnActivate(), DIALOG_FOOTPRINT_FP_EDITOR::OnAdd3DModel(), DIALOG_FOOTPRINT_BOARD_EDITOR::OnAdd3DModel(), DIALOG_GENCAD_EXPORT_OPTIONS::onBrowse(), KICAD_MANAGER_FRAME::OnBrowseInFileExplorer(), DIALOG_DRC_CONTROL::OnButtonBrowseRptFileClick(), DIALOG_EDIT_COMPONENTS_LIBID::onClickOrphansButton(), OnConfigurePaths(), FOOTPRINT_EDIT_FRAME::OnConfigurePaths(), KICAD_MANAGER_FRAME::OnCreateProjectFromTemplate(), OnEditFootprintLibraryTable(), DIALOG_GENDRILL::OnGenReportFile(), SCH_EDIT_FRAME::OnImportProject(), DIALOG_CHOOSE_COMPONENT::OnInitDialog(), KICAD_MANAGER_FRAME::OnOpenFileInTextEditor(), DIALOG_NETLIST::OnOpenNetlistClick(), DIALOG_EXPORT_SVG::OnOutputDirectoryBrowseClicked(), DIALOG_PLOT::OnOutputDirectoryBrowseClicked(), DIALOG_GENDRILL::OnOutputDirectoryBrowseClicked(), DIALOG_PLOT_SCHEMATIC::OnOutputDirectoryBrowseClicked(), LIB_EDIT_FRAME::OnPlotCurrentComponent(), DIALOG_SYMBOL_REMAP::OnRemapSymbols(), SCH_EDIT_FRAME::OnRightClick(), KICAD_MANAGER_FRAME::OnRunGerbview(), DIALOG_BOM::OnRunPlugin(), FOOTPRINT_EDIT_FRAME::OnSaveFootprintAsPng(), KICAD_MANAGER_FRAME::OnSaveProject(), DIALOG_SPICE_MODEL::onSelectLibrary(), LIB_VIEW_FRAME::OnSelectSymbol(), KICAD_MANAGER_FRAME::OnUnarchiveFiles(), LIB_EDIT_FRAME::OnViewEntryDoc(), LIB_VIEW_FRAME::onViewSymbolDocument(), SCH_EDIT_FRAME::OpenProjectFiles(), PCB_EDIT_FRAME::OpenProjectFiles(), PANEL_PREV_3D::PANEL_PREV_3D(), SCH_EDIT_FRAME::PasteListOfItems(), PCB_BASE_EDIT_FRAME::PCB_BASE_EDIT_FRAME(), DIALOG_CHOOSE_COMPONENT::PopulateFootprintSelector(), SCH_EDIT_FRAME::Process_Config(), ReadNetListAndFpFiles(), PCB_EDIT_FRAME::RecreateCmpFileFromBoard(), FOOTPRINT_VIEWER_FRAME::ReCreateFootprintList(), FOOTPRINT_VIEWER_FRAME::ReCreateLibraryList(), LIB_VIEW_FRAME::ReCreateListCmp(), LIB_VIEW_FRAME::ReCreateListLib(), EDA_3D_VIEWER::ReloadRequest(), DIALOG_SYMBOL_REMAP::remapSymbolToLibTable(), FOOTPRINT_EDIT_FRAME::restoreLastFootprint(), FOOTPRINT_EDIT_FRAME::retainLastFootprint(), SCH_EDIT_FRAME::SaveEEFile(), FOOTPRINT_EDIT_FRAME::SaveFootprint(), FOOTPRINT_EDIT_FRAME::SaveFootprintAs(), FOOTPRINT_EDIT_FRAME::saveFootprintInLibrary(), LIB_EDIT_FRAME::saveLibrary(), LIB_EDIT_FRAME::SaveOneSymbol(), LIB_EDIT_FRAME::savePartAs(), SCH_EDIT_FRAME::SaveProject(), SaveProjectFile(), SCH_EDIT_FRAME::SaveProjectSettings(), PCB_EDIT_FRAME::SaveProjectSettings(), SCH_BASE_FRAME::saveSymbolLibTables(), FOOTPRINT_VIEWER_FRAME::SelectAndViewFootprint(), SCH_BASE_FRAME::SelectComponentFromLibTree(), PCB_BASE_FRAME::SelectLibrary(), SCH_BASE_FRAME::SelectLibraryFromList(), LIB_EDIT_FRAME::selectSymLibTable(), FOOTPRINT_VIEWER_FRAME::setCurFootprintName(), LIB_EDIT_FRAME::SetCurLib(), FOOTPRINT_VIEWER_FRAME::setCurNickname(), LIB_EDIT_FRAME::SetCurPart(), KICAD_MANAGER_FRAME::SetProjectFileName(), DIALOG_CHOOSE_COMPONENT::ShowFootprintFor(), FOOTPRINT_VIEWER_FRAME::ShowModal(), SIM_PLOT_FRAME::SIM_PLOT_FRAME(), LIB_MANAGER::symTable(), FOOTPRINT_EDIT_FRAME::SyncLibraryTree(), EDA_3D_VIEWER::takeScreenshot(), DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::TransferDataFromWindow(), DIALOG_FOOTPRINT_FP_EDITOR::TransferDataToWindow(), DIALOG_FOOTPRINT_BOARD_EDITOR::TransferDataToWindow(), SIM_PLOT_FRAME::updateNetlistExporter(), SCH_SCREEN::UpdateSymbolLinks(), FOOTPRINT_VIEWER_FRAME::UpdateTitle(), FOOTPRINT_EDIT_FRAME::updateTitle(), DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::Validate(), SCH_EDIT_FRAME::WriteNetListFile(), DIALOG_FOOTPRINT_BOARD_EDITOR::~DIALOG_FOOTPRINT_BOARD_EDITOR(), DIALOG_FOOTPRINT_FP_EDITOR::~DIALOG_FOOTPRINT_FP_EDITOR(), LAUNCHER_PANEL::~LAUNCHER_PANEL(), and PCB_BASE_EDIT_FRAME::~PCB_BASE_EDIT_FRAME().

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:142
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 158 of file eda_base_frame.cpp.

References EDA_BASE_FRAME::findQuasiModalDialog(), 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 EDA_BASE_FRAME::isAutoSaveRequired(), STATUS_POPUP::onCharHook(), LIB_VIEW_FRAME::onSelectNextSymbol(), LIB_VIEW_FRAME::onSelectPreviousSymbol(), KIWAY::ProcessEvent(), LIB_VIEW_FRAME::ReCreateListCmp(), CVPCB_CONTROL::SwitchUnits(), GERBVIEW_CONTROL::SwitchUnits(), and PCBNEW_CONTROL::SwitchUnits().

159 {
160 #ifdef __WXMAC__
161  // Apple in its infinite wisdom will raise a disabled window before even passing
162  // us the event, so we have no way to stop it. Instead, we have to catch an
163  // improperly ordered disabled window and quasi-modal dialog here and reorder
164  // them.
165  if( !IsEnabled() && IsActive() )
166  {
167  wxWindow* dlg = findQuasiModalDialog();
168  if( dlg )
169  dlg->Raise();
170  }
171 #endif
172 
173  if( !wxFrame::ProcessEvent( aEvent ) )
174  return false;
175 
176  if( IsShown() && m_hasAutoSave && IsActive() &&
178  {
179  if( !m_autoSaveState )
180  {
181  wxLogTrace( traceAutoSave, wxT( "Starting auto save timer." ) );
182  m_autoSaveTimer->Start( m_autoSaveInterval * 1000, wxTIMER_ONE_SHOT );
183  m_autoSaveState = true;
184  }
185  else if( m_autoSaveTimer->IsRunning() )
186  {
187  wxLogTrace( traceAutoSave, wxT( "Stopping auto save timer." ) );
188  m_autoSaveTimer->Stop();
189  m_autoSaveState = false;
190  }
191  }
192 
193  return true;
194 }
bool m_autoSaveState
Flag to indicate the last auto save state.
const wxChar *const traceAutoSave
Flag to enable auto save feature debug tracing.
wxTimer * m_autoSaveTimer
The timer used to implement the auto save feature;.
wxWindow * findQuasiModalDialog()
virtual bool isAutoSaveRequired() const
Function autoSaveRequired returns the auto save status of the application.
bool m_hasAutoSave
Flag to indicate if this frame supports auto save.
int m_autoSaveInterval
The auto save interval time in seconds.
bool CVPCB_MAINFRAME::ReadNetListAndFpFiles ( const std::string &  aNetlist)

Function ReadNetListAndFpFiles loads the netlist file built on the fly by Eeschema and loads footprint libraries from fp lib tables.

Parameters
aNetlistis the netlist from eeschema in kicad s-expr format. (see CVPCB_MAINFRAME::KiwayMailIn() to know how to get this netlist)

Definition at line 167 of file readwrite_dlgs.cpp.

References DIALOG_FP_CONFLICT_ASSIGNMENT_SELECTOR::Add(), NETLIST::AnyFootprintsLinked(), COMPONENTS_LISTBOX::AppendLine(), BuildFOOTPRINTS_LISTBOX(), BuildLIBRARY_LISTBOX(), UTF8::c_str(), 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(), i, NETLIST::IsEmpty(), LIB_ID::IsLegacy(), IsOK(), KIWAY_HOLDER::Kiway(), HTML_MESSAGE_BOX::ListSet(), LoadFootprintFiles(), LoadProjectFile(), m_compListBox, m_modified, m_netlist, HTML_MESSAGE_BOX::MessageSet(), PROJECT::PcbFootprintLibs(), KIWAY_HOLDER::Prj(), ReadSchematicNetlist(), COMPONENT::SetFPID(), COMPONENTS_LISTBOX::SetSelection(), DIALOG_SHIM::Show(), TO_UTF8, and IO_ERROR::What().

Referenced by KiwayMailIn().

168 {
169  wxString msg;
170  bool hasMissingNicks = false;
171 
172  ReadSchematicNetlist( aNetlist );
173 
174  if( m_compListBox == NULL )
175  return false;
176 
177  LoadProjectFile();
178 
179  wxSafeYield();
180 
182 
185 
186  m_compListBox->Clear();
187 
189  {
190  for( unsigned i = 0; i < m_netlist.GetCount(); i++ )
191  {
192  COMPONENT* component = m_netlist.GetComponent( i );
193 
194  if( component->GetFPID().empty() )
195  continue;
196 
197  if( component->GetFPID().IsLegacy() )
198  hasMissingNicks = true;
199  }
200  }
201 
202  // Check if footprint links were generated before the footprint library table was implemented.
203  if( hasMissingNicks )
204  {
205  msg = _(
206  "Some of the assigned footprints are legacy entries (are missing lib nicknames). "
207  "Would you like CvPcb to attempt to convert them to the new required LIB_ID format? "
208  "(If you answer no, then these assignments will be cleared out and you will "
209  "have to re-assign these footprints yourself.)"
210  );
211 
212  if( IsOK( this, msg ) )
213  {
214  msg.Clear();
215 
216  try
217  {
218  for( unsigned i = 0; i < m_netlist.GetCount(); i++ )
219  {
220  COMPONENT* component = m_netlist.GetComponent( i );
221 
222  if( component->GetFPID().IsLegacy() )
223  {
224  // get this first here, it's possibly obsoleted if we get it too soon.
225  FP_LIB_TABLE* tbl = Prj().PcbFootprintLibs( Kiway() );
226 
227  int guess = guessNickname( tbl, (LIB_ID*) &component->GetFPID() );
228 
229  switch( guess )
230  {
231  case 0:
232  DBG(printf("%s: guessed OK ref:%s fpid:%s\n", __func__,
233  TO_UTF8( component->GetReference() ), component->GetFPID().Format().c_str() );)
234  m_modified = true;
235  break;
236 
237  case 1:
238  msg += wxString::Format( _(
239  "Component \"%s\" footprint \"%s\" was <b>not found</b> in any library.\n" ),
240  GetChars( component->GetReference() ),
241  GetChars( component->GetFPID().GetLibItemName() )
242  );
243  break;
244 
245  case 2:
246  msg += wxString::Format( _(
247  "Component \"%s\" footprint \"%s\" was found in <b>multiple</b> libraries.\n" ),
248  GetChars( component->GetReference() ),
249  GetChars( component->GetFPID().GetLibItemName() )
250  );
251  break;
252  }
253  }
254  }
255  }
256  catch( const IO_ERROR& ioe )
257  {
258  msg = ioe.What();
259  msg += wxT( "\n\n" );
260  msg += _( "First check your footprint library table entries." );
261 
262  wxMessageBox( msg, _( "Problematic Footprint Library Tables" ) );
263  return false;
264  }
265 
266  if( msg.size() )
267  {
268  HTML_MESSAGE_BOX dlg( this, wxEmptyString );
269 
270  dlg.MessageSet( _( "The following errors occurred attempting to convert the "
271  "footprint assignments:\n\n" ) );
272  dlg.ListSet( msg );
273  dlg.MessageSet( _( "\nYou will need to reassign them manually if you want them "
274  "to be updated correctly the next time you import the "
275  "netlist in Pcbnew." ) );
276 
277 #if 1
278  dlg.ShowModal();
279 #else
280  dlg.Fit();
281  dlg.Show( true ); // modeless lets user watch while fixing the problems, but its not working.
282 #endif
283  }
284  }
285  else
286  {
287  // Clear the legacy footprint assignments.
288  for( unsigned i = 0; i < m_netlist.GetCount(); i++ )
289  {
290  COMPONENT* component = m_netlist.GetComponent( i );
291 
292  if( component->GetFPID().IsLegacy() )
293  {
294  component->SetFPID( LIB_ID() /* empty */ );
295  m_modified = true;
296  }
297  }
298  }
299  }
300 
301 
302  // Display a dialog to select footprint selection, if the netlist
303  // and the .cmp file give 2 different valid footprints
304  std::vector <int > m_indexes; // indexes of footprints in netlist
305 
306  for( unsigned ii = 0; ii < m_netlist.GetCount(); ii++ )
307  {
308  COMPONENT* component = m_netlist.GetComponent( ii );
309 
310  if( component->GetAltFPID().empty() )
311  continue;
312 
313  if( component->GetFPID().IsLegacy() || component->GetAltFPID().IsLegacy())
314  continue;
315 
316  m_indexes.push_back( ii );
317  }
318 
319  // If a n assignment conflict is found,
320  // open a dialog to chose between schematic assignment
321  // and .cmp file assignment:
322  if( m_indexes.size() > 0 )
323  {
325 
326  for( unsigned ii = 0; ii < m_indexes.size(); ii++ )
327  {
328  COMPONENT* component = m_netlist.GetComponent( m_indexes[ii] );
329 
330  wxString cmpfpid = component->GetFPID().Format();
331  wxString schfpid = component->GetAltFPID().Format();
332 
333  dlg.Add( component->GetReference(), schfpid, cmpfpid );
334  }
335 
336  if( dlg.ShowModal() == wxID_OK )
337  {
338 
339  // Update the fp selection:
340  for( unsigned ii = 0; ii < m_indexes.size(); ii++ )
341  {
342  COMPONENT* component = m_netlist.GetComponent( m_indexes[ii] );
343 
344  int choice = dlg.GetSelection( component->GetReference() );
345 
346  if( choice == 0 ) // the schematic (alt fpid) is chosen:
347  component->SetFPID( component->GetAltFPID() );
348  }
349  }
350  }
351 
352  // Populates the component list box:
353  for( unsigned i = 0; i < m_netlist.GetCount(); i++ )
354  {
355  COMPONENT* component = m_netlist.GetComponent( i );
356 
357  msg.Printf( CMP_FORMAT, m_compListBox->GetCount() + 1,
358  GetChars( component->GetReference() ),
359  GetChars( component->GetValue() ),
360  GetChars( FROM_UTF8( component->GetFPID().Format().c_str() ) ) );
361 
362  m_compListBox->AppendLine( msg );
363  }
364 
365  if( !m_netlist.IsEmpty() )
366  m_compListBox->SetSelection( 0, true );
367 
368  DisplayStatus();
369 
370  return true;
371 }
bool empty() const
Definition: lib_id.h:186
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: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
bool AnyFootprintsLinked() const
Function AnyFootprintsLinked.
void SetFPID(const LIB_ID &aFPID)
Definition: pcb_netlist.h:155
COMPONENTS_LISTBOX * m_compListBox
bool IsLegacy() const
Definition: lib_id.h:176
void SetSelection(int index, bool State=true)
int ReadSchematicNetlist(const std::string &aNetlist)
Function ReadSchematicNetlist read the netlist (.net) file built on the fly by Eeschema.
bool IsEmpty() const
Function IsEmpty()
Definition: pcb_netlist.h:244
A logical library item identifier and consists of various portions much like a URI.
Definition: lib_id.h:51
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:151
const wxString & GetValue() const
Definition: pcb_netlist.h:153
#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
Definition: lib_id.h:114
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:265
#define CMP_FORMAT
Definition: cvpcb.h:30
const LIB_ID & GetAltFPID() const
Definition: pcb_netlist.h:168
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
const char * c_str() const
Definition: utf8.h:107
size_t i
Definition: json11.cpp:597
UTF8 Format() const
Definition: lib_id.cpp:237
#define DBG(x)
Definition: fctsys.h:33
unsigned GetCount() const
Function GetCount.
Definition: pcb_netlist.h:256
Struct IO_ERROR is a class used to hold an error message and may be used when throwing exceptions con...
Definition: ki_exception.h:76
bool IsOK(wxWindow *aParent, const wxString &aMessage)
Function IsOK displays a yes/no dialog with aMessage and returns the user response.
Definition: confirm.cpp:295
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)

Function ReadSchematicNetlist read the netlist (.net) file built on the fly by Eeschema.

Parameters
aNetlistis the netlist buffer filled by eeschema, in kicad s-expr format. It is the same netlist as the .net file created by Eeschema. (This method is called by ReadNetListAndFpFiles)

Definition at line 744 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 ReadNetListAndFpFiles().

745 {
746  STRING_LINE_READER* strrdr = new STRING_LINE_READER( aNetlist, "Eeschema via Kiway" );
747  KICAD_NETLIST_READER netrdr( strrdr, &m_netlist );
748 
749  m_netlist.Clear();
750 
751  try
752  {
753  netrdr.LoadNetlist();
754  }
755  catch( const IO_ERROR& ioe )
756  {
757  wxString msg = wxString::Format( _( "Error loading schematic.\n%s" ), ioe.What().GetData() );
758  wxMessageBox( msg, _( "Load Error" ), wxOK | wxICON_ERROR );
759  return 1;
760  }
761 
762  // We also remove footprint name if it is "$noname" because this is a dummy name,
763  // not the actual name of the footprint.
764  for( unsigned ii = 0; ii < m_netlist.GetCount(); ii++ )
765  {
766  if( m_netlist.GetComponent( ii )->GetFPID().GetLibItemName() == std::string( "$noname" ) )
767  m_netlist.GetComponent( ii )->SetFPID( LIB_ID() );
768  }
769 
770  // Sort components by reference:
772 
773  return 0;
774 }
const LIB_ID & GetFPID() const
Definition: pcb_netlist.h:166
Class KICAD_NETLIST_READER read the new s-expression based KiCad netlist format.
void SetFPID(const LIB_ID &aFPID)
Definition: pcb_netlist.h:155
A logical library item identifier and consists of various portions much like a URI.
Definition: lib_id.h:51
void SortByReference()
const UTF8 & GetLibItemName() const
Definition: lib_id.h:114
COMPONENT * GetComponent(unsigned aIndex)
Function GetComponent returns the COMPONENT at aIndex.
Definition: pcb_netlist.h:265
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:250
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:256
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:76
void CVPCB_MAINFRAME::ReCreateHToolbar ( void  )

Definition at line 35 of file toolbars_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, EDA_BASE_FRAME::KICAD_AUI_TB_STYLE, KiScaledBitmap(), KiScaledSeparator(), m_mainToolBar, and m_tcFilterString.

Referenced by CVPCB_MAINFRAME(), and ShowChangedLanguage().

36 {
37  if( m_mainToolBar )
38  m_mainToolBar->Clear();
39  else
40  m_mainToolBar = new wxAuiToolBar( this, ID_H_TOOLBAR, wxDefaultPosition, wxDefaultSize,
41  KICAD_AUI_TB_STYLE | wxAUI_TB_HORZ_LAYOUT );
42 
43  m_mainToolBar->AddTool( ID_CVPCB_LIB_TABLE_EDIT, wxEmptyString,
44  KiScaledBitmap( config_xpm, this ),
45  _( "Edit footprint library table" ) );
46 
48  m_mainToolBar->AddTool( ID_CVPCB_CREATE_SCREENCMP, wxEmptyString,
49  KiScaledBitmap( show_footprint_xpm, this ),
50  _( "View selected footprint" ) );
51 
53  m_mainToolBar->AddTool( ID_CVPCB_GOTO_PREVIOUSNA, wxEmptyString,
54  KiScaledBitmap( left_xpm, this ),
55  _( "Select previous unlinked symbol" ) );
56 
57  m_mainToolBar->AddTool( ID_CVPCB_GOTO_FIRSTNA, wxEmptyString,
58  KiScaledBitmap( right_xpm, this ),
59  _( "Select next unlinked symbol" ) );
60 
62  m_mainToolBar->AddTool( ID_CVPCB_AUTO_ASSOCIE, wxEmptyString,
63  KiScaledBitmap( auto_associe_xpm, this ),
64  _( "Perform automatic footprint association" ) );
65 
66  m_mainToolBar->AddTool( ID_CVPCB_DEL_ASSOCIATIONS, wxEmptyString,
67  KiScaledBitmap( delete_association_xpm, this ),
68  _( "Delete all footprint associations" ) );
69 
72  KiScaledBitmap( module_filtered_list_xpm, this ),
73  wxNullBitmap,
74  true, NULL,
75  _( "Filter footprint list by schematic symbol keywords" ),
76  wxEmptyString );
77 
79  KiScaledBitmap( module_pin_filtered_list_xpm, this ),
80  wxNullBitmap,
81  true, NULL,
82  _( "Filter footprint list by pin count" ),
83  wxEmptyString );
84 
86  KiScaledBitmap( module_library_list_xpm, this ),
87  wxNullBitmap, true, NULL,
88  _( "Filter footprint list by library" ),
89  wxEmptyString );
90 
93  KiScaledBitmap( module_name_filtered_list_xpm, this ),
94  wxNullBitmap, true, NULL,
95  _( "Filter footprint list using a partial name or a pattern" ),
96  wxEmptyString );
97 
99 
100  m_mainToolBar->AddControl( m_tcFilterString );
101 
102 
103  // after adding the buttons to the toolbar, must call Realize() to reflect the changes
104  m_mainToolBar->Realize();
105 }
wxBitmap KiScaledBitmap(BITMAP_DEF aBitmap, EDA_BASE_FRAME *aWindow)
Construct a wxBitmap from a memory record, scaling it if device DPI demands it.
Definition: bitmap.cpp:116
wxTextCtrl * m_tcFilterString
wxAuiToolBar * m_mainToolBar
void KiScaledSeparator(wxAuiToolBar *aToolbar, EDA_BASE_FRAME *aWindow)
Add a separator to the given toolbar scaled the same way as KiScaledBitmap.
Definition: bitmap.cpp:167
static constexpr int KICAD_AUI_TB_STYLE
Default style flags used for wxAUI toolbars
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_EQUFILES_LIST_EDIT, ID_CVPCB_LIB_TABLE_EDIT, ID_PREFERENCES_CONFIGURE_PATHS, KiBitmap(), Pgm(), and SAVE_HLP_MSG.

Referenced by CVPCB_MAINFRAME().

44 {
45  // wxWidgets handles the Mac Application menu behind the scenes, but that means
46  // we always have to start from scratch with a new wxMenuBar.
47  wxMenuBar* oldMenuBar = GetMenuBar();
48  wxMenuBar* menuBar = new wxMenuBar();
49 
50  // Recreate all menus:
51 
52  // Menu File:
53  wxMenu* filesMenu = new wxMenu;
54 
55  // Save the footprints back into eeschema
56  AddMenuItem( filesMenu, wxID_SAVE,
57  _( "&Save Schematic\tCtrl+S" ),
59  KiBitmap( save_xpm ) );
60 
61  // Preferences Menu :
62  wxMenu* preferencesMenu = new wxMenu;
63 
64  // Path configuration edit dialog.
65  AddMenuItem( preferencesMenu,
67  _( "&Configure Paths..." ),
68  _( "Edit path configuration environment variables" ),
69  KiBitmap( editor_xpm ) );
70 
71  AddMenuItem( preferencesMenu, ID_CVPCB_LIB_TABLE_EDIT,
72  _( "Manage &Footprint Libraries..." ), _( "Manage footprint libraries" ),
73  KiBitmap( library_table_xpm ) );
74 
75  preferencesMenu->AppendSeparator();
76  AddMenuItem( preferencesMenu, ID_CVPCB_EQUFILES_LIST_EDIT,
77  _( "Footprint &Association Files..." ),
78  _( "Configure footprint association file (.equ) list."
79  "These files are used to automatically assign "
80  "the footprint name from the symbol value" ),
81  KiBitmap( library_table_xpm ) );
82  preferencesMenu->AppendSeparator();
83 
84  // Language submenu
85  Pgm().AddMenuLanguageList( preferencesMenu );
86 
87  // Menu Help:
88  wxMenu* helpMenu = new wxMenu;
89 
90  // Manual Contents
91  AddMenuItem( helpMenu, wxID_HELP, _( "CvPcb &Manual" ),
92  _( "Open CvPcb Manual" ),
93  KiBitmap( online_help_xpm ) );
94 
95  AddMenuItem( helpMenu,
96  wxID_INDEX,
97  _( "&Getting Started in KiCad" ),
98  _( "Open \"Getting Started in KiCad\" guide for beginners" ),
99  KiBitmap( help_xpm ) );
100 
101  // About CvPcb
102  AddMenuItem( helpMenu, wxID_ABOUT, _( "&About KiCad" ), KiBitmap( about_xpm ) );
103 
104  // Create the menubar and append all submenus
105  menuBar->Append( filesMenu, _( "&File" ) );
106  menuBar->Append( preferencesMenu, _( "&Preferences" ) );
107  menuBar->Append( helpMenu, _( "&Help" ) );
108 
109  SetMenuBar( menuBar );
110  delete oldMenuBar;
111 }
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:223
PGM_BASE & Pgm()
The global Program "get" accessor.
Definition: kicad.cpp:66
wxBitmap KiBitmap(BITMAP_DEF aBitmap)
Construct a wxBitmap from a memory record, held in a BITMAP_DEF.
Definition: bitmap.cpp:79
#define SAVE_HLP_MSG
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:800
void CVPCB_MAINFRAME::refreshAfterComponentSearch ( COMPONENT component)
private

Definition at line 492 of file cvpcb_mainframe.cpp.

References UTF8::c_str(), 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().

493 {
494  // Tell AuiMgr that objects are changed !
495  if( m_auimgr.GetManagedWindow() ) // Be sure Aui Manager is initialized
496  // (could be not the case when starting CvPcb
497  m_auimgr.Update();
498 
499  if( component == NULL )
500  {
501  DisplayStatus();
502  return;
503  }
504 
505  // Preview of the already assigned footprint.
506  // Find the footprint that was already chosen for this component and select it,
507  // but only if the selection is made from the component list or the library list.
508  // If the selection is made from the footprint list, do not change the current
509  // selected footprint.
510  if( FindFocus() == m_compListBox || FindFocus() == m_libListBox )
511  {
512  wxString module = FROM_UTF8( component->GetFPID().Format().c_str() );
513 
515 
516  for( int ii = 0; ii < m_footprintListBox->GetCount(); ii++ )
517  {
518  wxString footprintName;
519  wxString msg = m_footprintListBox->OnGetItemText( ii, 0 );
520  msg.Trim( true );
521  msg.Trim( false );
522  footprintName = msg.AfterFirst( wxChar( ' ' ) );
523 
524  if( module.Cmp( footprintName ) == 0 )
525  {
526  m_footprintListBox->SetSelection( ii, true );
527  break;
528  }
529  }
530 
532  CreateScreenCmp();
533  }
534 
536  DisplayStatus();
537 }
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: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
COMPONENTS_LISTBOX * m_compListBox
wxAuiManager m_auimgr
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()
const char * c_str() const
Definition: utf8.h:107
FOOTPRINTS_LISTBOX * m_footprintListBox
UTF8 Format() const
Definition: lib_id.cpp:237
void DisplayStatus()
Function DisplayStatus updates the information displayed on the status bar at bottom of the main fram...
bool CVPCB_MAINFRAME::SaveFootprintAssociation ( bool  doSaveSchematic)

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

Optionally saves the schematic to disk as well.

Definition at line 374 of file readwrite_dlgs.cpp.

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

Referenced by OnCloseWindow(), OnOK(), and OnSaveAndContinue().

375 {
376  STRING_FORMATTER sf;
377 
379 
381 
382  if( doSaveSchematic )
383  Kiway().ExpressMail( FRAME_SCH, MAIL_SCH_SAVE, std::string( "" ) );
384 
385  return true; // we can't tell if it was successful, so just assume the best
386 }
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.
Definition: mail_type.h:40
CVPCB->SCH save the schematic.
Definition: mail_type.h:41
VTBL_ENTRY void ExpressMail(FRAME_T aDestination, MAIL_T aCommand, std::string aPayload, wxWindow *aSource=NULL)
Function ExpressMail send aPayload to aDestination from aSource.
Definition: kiway.cpp:386
const std::string & GetString()
Definition: richio.h:475
void FormatBackAnnotation(OUTPUTFORMATTER *aOut)
Definition: pcb_netlist.h:355
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:318
Class PROJECT holds project specific data.
Definition: project.h:57
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.
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 283 of file eda_base_frame.h.

References EDA_BASE_FRAME::ExportHotkeyConfigToFile(), EDA_BASE_FRAME::GetFileFromHistory(), EDA_BASE_FRAME::ImportHotkeyConfigFromFile(), EDA_BASE_FRAME::UpdateFileHistory(), and EDA_BASE_FRAME::WriteHotkeyConfig().

Referenced by DIALOG_PAGES_SETTINGS::OnOkClick(), and SCH_EDIT_FRAME::Process_Config().

283 {};
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 245 of file cvpcb_mainframe.cpp.

References FilterFootprintEntry, m_filteringOptions, and EDA_BASE_FRAME::SaveSettings().

246 {
248 
250 }
virtual void SaveSettings(wxConfigBase *aCfg)
Function SaveSettings saves common frame parameters to a configuration data file. ...
static const wxString FilterFootprintEntry
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 720 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(), numEval::StrPrintf(), and TO_UTF8.

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

721 {
722  if( m_netlist.IsEmpty() )
723  return;
724 
725  int selection = m_compListBox->GetSelection();
726 
727  if ( selection < 0 )
728  selection = 0;
729 
730  if( m_netlist.GetComponent( selection ) == NULL )
731  return;
732 
733  COMPONENT* component = m_netlist.GetComponent( selection );
734 
735  std::string packet = StrPrintf( "$PART: \"%s\"", TO_UTF8( component->GetReference() ) );
736 
737  if( Kiface().IsSingle() )
738  SendCommand( MSG_TO_SCH, packet.c_str() );
739  else
740  Kiway().ExpressMail( FRAME_SCH, MAIL_CROSS_PROBE, packet, this );
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
int StrPrintf(std::string *aResult, const char *aFormat,...)
Function StrPrintf is like sprintf() but the output is appended to a std::string instead of to a char...
Definition: richio.cpp:74
COMPONENTS_LISTBOX * m_compListBox
#define MSG_TO_SCH
Definition: eda_dde.h:46
bool SendCommand(int service, const char *cmdline)
Definition: eda_dde.cpp:132
bool IsEmpty() const
Function IsEmpty()
Definition: pcb_netlist.h:244
KIFACE_I & Kiface()
Global KIFACE_I "get" accessor.
Definition: kicad.cpp:52
VTBL_ENTRY void ExpressMail(FRAME_T aDestination, MAIL_T aCommand, std::string aPayload, wxWindow *aSource=NULL)
Function ExpressMail send aPayload to aDestination from aSource.
Definition: kiway.cpp:386
const wxString & GetReference() 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:265
PCB<->SCH, CVPCB->SCH cross-probing.
Definition: mail_type.h:39
void EDA_BASE_FRAME::SetAutoSaveInterval ( int  aInterval)
inherited

Definition at line 197 of file eda_base_frame.cpp.

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

Referenced by EDA_DRAW_FRAME::CommonSettingsChanged(), and EDA_BASE_FRAME::isAutoSaveRequired().

198 {
199  m_autoSaveInterval = aInterval;
200 
201  if( m_autoSaveTimer->IsRunning() )
202  {
203  if( m_autoSaveInterval > 0 )
204  {
205  m_autoSaveTimer->Start( m_autoSaveInterval * 1000, wxTIMER_ONE_SHOT );
206  }
207  else
208  {
209  m_autoSaveTimer->Stop();
210  m_autoSaveState = false;
211  }
212  }
213 }
bool m_autoSaveState
Flag to indicate the last auto save state.
wxTimer * m_autoSaveTimer
The timer used to implement the auto save feature;.
int m_autoSaveInterval
The auto save interval time in seconds.
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 47 of file kiway_holder.cpp.

References KIWAY_HOLDER::m_kiway, and name.

Referenced by DIALOG_SHIM::DIALOG_SHIM(), InvokePcbLibTableEditor(), KIWAY_HOLDER::Kiway(), and SIM_PLOT_FRAME::SIM_PLOT_FRAME().

48 {
49 #if defined(DEBUG)
50  // offer a trap point for debugging most any window
51  wxASSERT( aDest );
52  if( !strcmp( typeid(aDest).name(), "DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB" ) )
53  {
54  int breakhere=1;
55  (void) breakhere;
56  }
57 #endif
58 
59  (void) aDest;
60 
61  m_kiway = aKiway;
62 }
KIWAY * m_kiway
Definition: kiway_player.h:94
const char * name
Definition: DXF_plotter.cpp:61
void KIWAY_PLAYER::SetModal ( bool  aIsModal)
inlineprotectedinherited

Definition at line 227 of file kiway_player.h.

Referenced by FOOTPRINT_VIEWER_FRAME::FOOTPRINT_VIEWER_FRAME().

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

Definition at line 346 of file eda_base_frame.h.

Referenced by KICAD_MANAGER_FRAME::LoadProject().

346 { m_mruPath = aPath; }
wxString m_mruPath
Most recently used path.
void CVPCB_MAINFRAME::SetNewPkg ( const wxString &  aFootprintName)

Function SetNewPkg set the footprint name for all selected components in component list and selects the next component.

Parameters
aFootprintName= the new footprint name

Definition at line 45 of file readwrite_dlgs.cpp.

References DisplayStatus(), NETLIST::GetComponent(), COMPONENTS_LISTBOX::GetCount(), NETLIST::IsEmpty(), m_compListBox, m_netlist, and COMPONENTS_LISTBOX::SetSelection().

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

46 {
47  COMPONENT* component;
48  int componentIndex;
49 
50  if( m_netlist.IsEmpty() )
51  return;
52 
53  // If no component is selected, select the first one
54  if( m_compListBox->GetFirstSelected() < 0 )
55  {
56  componentIndex = 0;
57  m_compListBox->SetSelection( componentIndex, true );
58  }
59 
60  // iterate over the selection
61  while( m_compListBox->GetFirstSelected() != -1 )
62  {
63  // Get the component for the current iteration
64  componentIndex = m_compListBox->GetFirstSelected();
65  component = m_netlist.GetComponent( componentIndex );
66 
67  if( component == NULL )
68  return;
69 
70  SetNewPkg( aFootprintName, componentIndex );
71 
72  m_compListBox->SetSelection( componentIndex, false );
73  }
74 
75  // select the next component, if there is one
76  if( componentIndex < (m_compListBox->GetCount() - 1) )
77  componentIndex++;
78 
79  m_compListBox->SetSelection( componentIndex, true );
80 
81  // update the statusbar
82  DisplayStatus();
83 }
COMPONENTS_LISTBOX * m_compListBox
void SetSelection(int index, bool State=true)
void SetNewPkg(const wxString &aFootprintName)
Function SetNewPkg set the footprint name for all selected components in component list and selects t...
bool IsEmpty() const
Function IsEmpty()
Definition: pcb_netlist.h:244
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:265
void DisplayStatus()
Function DisplayStatus updates the information displayed on the status bar at bottom of the main fram...
void CVPCB_MAINFRAME::SetNewPkg ( const wxString &  aFootprintName,
int  aIndex 
)

Function SetNewPkg Set the footprint name for the component of position aIndex in the component list.

Parameters
aFootprintName= the new footprint name
aIndex= the index of the component to modify in the component list

Definition at line 86 of file readwrite_dlgs.cpp.

References UTF8::c_str(), CMP_FORMAT, DisplayStatus(), LIB_ID::Format(), Format(), FROM_UTF8(), GetChars(), NETLIST::GetComponent(), COMPONENT::GetFPID(), COMPONENT::GetReference(), COMPONENT::GetValue(), LIB_ID::ID_PCB, NETLIST::IsEmpty(), m_compListBox, m_modified, m_netlist, LIB_ID::Parse(), COMPONENT::SetFPID(), and COMPONENTS_LISTBOX::SetString().

87 {
88  COMPONENT* component;
89 
90  if( m_netlist.IsEmpty() )
91  return;
92 
93  component = m_netlist.GetComponent( aIndex );
94 
95  if( component == NULL )
96  return;
97 
98  LIB_ID fpid;
99 
100  if( !aFootprintName.IsEmpty() )
101  {
102  wxCHECK_RET( fpid.Parse( aFootprintName, LIB_ID::ID_PCB ) < 0,
103  wxString::Format( _( "\"%s\" is not a valid LIB_ID." ), aFootprintName ) );
104  }
105 
106  component->SetFPID( fpid );
107 
108  // create the new component description
109  wxString description = wxString::Format( CMP_FORMAT, aIndex + 1,
110  GetChars( component->GetReference() ),
111  GetChars( component->GetValue() ),
112  GetChars( FROM_UTF8( component->GetFPID().Format().c_str() ) ) );
113 
114  // Set the new description and deselect the processed component
115  m_compListBox->SetString( aIndex, description );
116 
117  // Mark this "session" as modified
118  m_modified = true;
119 
120  // update the statusbar
121  DisplayStatus();
122 }
const LIB_ID & GetFPID() const
Definition: pcb_netlist.h: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
void SetFPID(const LIB_ID &aFPID)
Definition: pcb_netlist.h:155
COMPONENTS_LISTBOX * m_compListBox
bool IsEmpty() const
Function IsEmpty()
Definition: pcb_netlist.h:244
A logical library item identifier and consists of various portions much like a URI.
Definition: lib_id.h:51
const wxString & GetReference() const
Definition: pcb_netlist.h:151
const wxString & GetValue() const
Definition: pcb_netlist.h:153
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:265
#define CMP_FORMAT
Definition: cvpcb.h:30
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
const char * c_str() const
Definition: utf8.h:107
void SetString(unsigned linecount, const wxString &text)
UTF8 Format() const
Definition: lib_id.cpp:237
int Parse(const UTF8 &aId, LIB_ID_TYPE aType, bool aFix=false)
Parse LIB_ID with the information from aId.
Definition: lib_id.cpp:122
void DisplayStatus()
Function DisplayStatus updates the information displayed on the status bar at bottom of the main fram...
void CVPCB_MAINFRAME::SetStatusText ( const wxString &  aText,
int  aNumber = 0 
)
override

Definition at line 921 of file cvpcb_mainframe.cpp.

References m_statusLine1, and m_statusLine2.

Referenced by AutomaticFootprintMatching(), DisplayStatus(), and KiwayMailIn().

922 {
923  wxASSERT( aNumber < 2 );
924 
925  if( aNumber == 1 )
926  m_statusLine2->SetLabel( aText );
927  else
928  m_statusLine1->SetLabel( aText );
929 }
wxStaticText * m_statusLine2
wxStaticText * m_statusLine1
void CVPCB_MAINFRAME::ShowChangedLanguage ( )
overridevirtual

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

Reimplemented from EDA_BASE_FRAME.

Definition at line 939 of file cvpcb_mainframe.cpp.

References DisplayStatus(), ReCreateHToolbar(), and EDA_BASE_FRAME::ShowChangedLanguage().

940 {
943  DisplayStatus();
944 }
virtual void ShowChangedLanguage()
Function ShowChangedLanguage redraws the menus and what not in current language.
void DisplayStatus()
Function DisplayStatus updates the information displayed on the status bar at bottom of the main fram...
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 77 of file kiway_player.cpp.

References 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, and WX_EVENT_LOOP.

Referenced by FIELDS_GRID_TRICKS::doPopupSelection(), FIELDS_EDITOR_GRID_TRICKS::doPopupSelection(), TEXT_BUTTON_SYMBOL_CHOOSER::OnButtonClick(), TEXT_BUTTON_FP_CHOOSER::OnButtonClick(), DIALOG_EDIT_ONE_FIELD::OnTextValueSelectButtonClick(), FOOTPRINT_EDIT_FRAME::Process_Special_Functions(), SCH_BASE_FRAME::SelectComponentFromLibBrowser(), FOOTPRINT_VIEWER_FRAME::ShowModal(), and DIALOG_EXCHANGE_FOOTPRINTS::ViewAndSelectFootprint().

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

Definition at line 513 of file eda_base_frame.cpp.

References KIWAY::CommonSettingsChanged(), PAGED_DIALOG::GetTreebook(), i, EDA_BASE_FRAME::InstallPreferences(), KIWAY_HOLDER::Kiway(), KIWAY_PLAYER_COUNT, and KIWAY::Player().

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

515 {
516  PAGED_DIALOG dlg( this, _( "Preferences" ) );
517  wxTreebook* book = dlg.GetTreebook();
518 
519  book->AddPage( new PANEL_COMMON_SETTINGS( &dlg, book ), _( "Common" ) );
520  book->AddPage( new PANEL_HOTKEYS_EDITOR( this, book, false,
521  aHotkeys, aShowHotkeys, aHotkeysNickname ), _( "Hotkeys" ) );
522 
523  for( unsigned i = 0; i < KIWAY_PLAYER_COUNT; ++i )
524  {
525  KIWAY_PLAYER* frame = dlg.Kiway().Player( (FRAME_T) i, false );
526 
527  if( frame )
528  frame->InstallPreferences( &dlg );
529  }
530 
531  if( dlg.ShowModal() == wxID_OK )
532  {
533  dlg.Kiway().CommonSettingsChanged();
534  return true;
535  }
536 
537  return false;
538 }
Class KIWAY_PLAYER is a wxFrame capable of the OpenProjectFiles function, meaning it can load a porti...
Definition: kiway_player.h:120
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
FRAME_T
Enum FRAME_T is the set of EDA_BASE_FRAME derivatives, typically stored in EDA_BASE_FRAME::m_Ident.
Definition: frame_type.h:34
VTBL_ENTRY KIWAY_PLAYER * Player(FRAME_T aFrameType, bool doCreate=true, wxTopLevelWindow *aParent=NULL)
Function Player returns the KIWAY_PLAYER* given a FRAME_T.
Definition: kiway.cpp:300
size_t i
Definition: json11.cpp:597
virtual void InstallPreferences(PAGED_DIALOG *aParent)
Function InstallPreferences allows a Frame to load its preference panels (if any) into the preference...
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 369 of file eda_base_frame.cpp.

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

Referenced by EDA_BASE_FRAME::GetKicadHelp(), and EDA_BASE_FRAME::isAutoSaveRequired().

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

Definition at line 306 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().

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

Definition at line 336 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().

337 {
338  if( m_netlist.IsEmpty() )
339  return;
340 
341  int first_selected = m_compListBox->GetFirstSelected();
342 
343  if( first_selected < 0 )
344  first_selected = m_compListBox->GetCount();
345 
346  int candidate = -1;
347 
348  for( int jj = first_selected-1; jj >= 0; jj-- )
349  {
350  if( m_netlist.GetComponent( jj )->GetFPID().empty() )
351  {
352  candidate = jj;
353  break;
354  }
355  }
356 
357  if( candidate >= 0 )
358  {
360  m_compListBox->SetSelection( candidate );
362  }
363 }
void SendMessageToEESCHEMA()
Function SendMessageToEESCHEMA Send a remote command to Eeschema via a socket, Commands are $PART: "r...
bool empty() const
Definition: lib_id.h:186
const LIB_ID & GetFPID() const
Definition: pcb_netlist.h:166
COMPONENTS_LISTBOX * m_compListBox
void DeselectAll()
Removes all selection in lists which can have more than one item selected.
void SetSelection(int index, bool State=true)
bool IsEmpty() const
Function IsEmpty()
Definition: pcb_netlist.h:244
COMPONENT * GetComponent(unsigned aIndex)
Function GetComponent returns the COMPONENT at aIndex.
Definition: pcb_netlist.h:265
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 387 of file eda_base_frame.cpp.

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

Referenced by SCH_EDIT_FRAME::importFile(), GERBVIEW_FRAME::LoadExcellonFiles(), GERBVIEW_FRAME::loadListOfGerberFiles(), PL_EDITOR_FRAME::LoadPageLayoutDescrFile(), KICAD_MANAGER_FRAME::LoadProject(), KICAD_MANAGER_FRAME::OnCloseWindow(), SCH_EDIT_FRAME::OpenProjectFiles(), PCB_EDIT_FRAME::OpenProjectFiles(), PCB_EDIT_FRAME::SavePcbFile(), EDA_BASE_FRAME::SaveProjectSettings(), and GERBVIEW_FRAME::unarchiveFiles().

389 {
390  wxFileHistory* fileHistory = aFileHistory;
391 
392  if( !fileHistory )
393  fileHistory = &Kiface().GetFileHistory();
394 
395  fileHistory->AddFileToHistory( FullFileName );
396 }
KIFACE_I & Kiface()
Global KIFACE_I "get" accessor.
Definition: kicad.cpp:52
FILE_HISTORY & GetFileHistory()
Definition: kiface_i.h:123
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 489 of file hotkeys_basic.cpp.

References AddDelimiterString(), DEFAULT_HOTKEY_FILENAME_EXT, EESCHEMA_HOTKEY_NAME, FOOTPRINT_EDIT_FRAME_NAME, GetChars(), GetKicadConfigPath(), KeyNameFromKeyCode(), LIB_EDIT_FRAME_NAME, EDA_HOTKEY_CONFIG::m_HK_InfoList, EDA_HOTKEY::m_InfoMsg, EDA_HOTKEY::m_KeyCode, EDA_HOTKEY_CONFIG::m_SectionTag, EDA_HOTKEY_CONFIG::m_Title, PCB_EDIT_FRAME_NAME, PCBNEW_HOTKEY_NAME, and SCH_EDIT_FRAME_NAME.

Referenced by EDA_BASE_FRAME::SaveProjectSettings(), PANEL_HOTKEYS_EDITOR::TransferDataFromWindow(), and EDA_DRAW_FRAME::WriteHotkeyConfig().

491 {
492  wxString msg;
493  wxString keyname, infokey;
494  FILE* file;
495 
496  msg = wxT( "$hotkey list\n" );
497 
498  // Print the current hotkey list
499  EDA_HOTKEY** list;
500 
501  for( ; aDescList->m_HK_InfoList != nullptr; aDescList++ )
502  {
503  if( aDescList->m_Title )
504  {
505  msg += wxT( "# " );
506  msg += *aDescList->m_Title;
507  msg += wxT( "\n" );
508  }
509 
510  msg += *aDescList->m_SectionTag;
511  msg += wxT( "\n" );
512 
513  list = aDescList->m_HK_InfoList;
514 
515  for( ; *list != nullptr; list++ )
516  {
517  EDA_HOTKEY* hk_decr = *list;
518  msg += wxT( "shortcut " );
519  keyname = KeyNameFromKeyCode( hk_decr->m_KeyCode );
520  AddDelimiterString( keyname );
521  infokey = hk_decr->m_InfoMsg;
522  AddDelimiterString( infokey );
523  msg += keyname + wxT( ": " ) + infokey + wxT( "\n" );
524  }
525  }
526 
527  msg += wxT( "$Endlist\n" );
528 
529  if( aFullFileName )
530  file = wxFopen( *aFullFileName, wxT( "wt" ) );
531  else
532  {
533  wxString configName( ConfigBaseName() );
534  if( configName == SCH_EDIT_FRAME_NAME || configName == LIB_EDIT_FRAME_NAME )
535  configName = EESCHEMA_HOTKEY_NAME;
536  else if( configName == PCB_EDIT_FRAME_NAME ||
537  configName == FOOTPRINT_EDIT_FRAME_NAME )
538  configName = PCBNEW_HOTKEY_NAME;
539 
540  wxFileName fn( configName );
541  fn.SetExt( DEFAULT_HOTKEY_FILENAME_EXT );
542  fn.SetPath( GetKicadConfigPath() );
543  file = wxFopen( fn.GetFullPath(), wxT( "wt" ) );
544  }
545 
546  if( file )
547  {
548  wxFputs( msg, file );
549  fclose( file );
550  }
551  else
552  {
553  msg.Printf( wxT( "Unable to write file %s" ), GetChars( *aFullFileName ) );
554  return 0;
555  }
556 
557  return 1;
558 }
#define LIB_EDIT_FRAME_NAME
Definition: draw_frame.h:49
EDA_HOTKEY ** m_HK_InfoList
Definition: hotkeys_basic.h:98
wxString ConfigBaseName()
Function ConfigBaseName.
#define PCB_EDIT_FRAME_NAME
Definition: draw_frame.h:56
#define SCH_EDIT_FRAME_NAME
Definition: draw_frame.h:50
#define FOOTPRINT_EDIT_FRAME_NAME
Definition: draw_frame.h:53
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 GetKicadConfigPath()
Return the user configuration path used to store KiCad&#39;s configuration files.
Definition: common.cpp:263
wxString * m_SectionTag
Definition: hotkeys_basic.h:97
wxString m_InfoMsg
Definition: hotkeys_basic.h:66
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:59
wxString * m_Title
Definition: hotkeys_basic.h:99
#define EESCHEMA_HOTKEY_NAME
Definition: hotkeys_basic.h:35
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
#define PCBNEW_HOTKEY_NAME
Definition: hotkeys_basic.h:36

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 139 of file eda_base_frame.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 134 of file eda_base_frame.h.

Referenced by EDA_BASE_FRAME::ConfigBaseName(), and FOOTPRINT_VIEWER_FRAME::FOOTPRINT_VIEWER_FRAME().

wxString CVPCB_MAINFRAME::m_currentSearchPattern
private
wxArrayString CVPCB_MAINFRAME::m_EquFilesNames
bool EDA_BASE_FRAME::m_hasAutoSave
protectedinherited

Flag to indicate if this frame supports auto save.

Definition at line 144 of file eda_base_frame.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 130 of file eda_base_frame.h.

Referenced by EDA_BASE_FRAME::EDA_BASE_FRAME(), and EDA_BASE_FRAME::findQuasiModalDialog().

bool CVPCB_MAINFRAME::m_initialized
protected

Definition at line 85 of file cvpcb_mainframe.h.

Referenced by CVPCB_MAINFRAME(), and DisplayStatus().

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

Definition at line 64 of file cvpcb_mainframe.h.

Referenced by CVPCB_MAINFRAME(), and ReCreateHToolbar().

bool KIWAY_PLAYER::m_modal
protectedinherited

Definition at line 249 of file kiway_player.h.

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

Definition at line 251 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 252 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 74 of file cvpcb_mainframe.h.

Referenced by LoadProjectFile().

wxString EDA_BASE_FRAME::m_perspective
protectedinherited

wxAuiManager perspective.

Definition at line 155 of file eda_base_frame.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().

wxButton* CVPCB_MAINFRAME::m_saveAndContinue
private

Definition at line 71 of file cvpcb_mainframe.h.

Referenced by CVPCB_MAINFRAME(), and ~CVPCB_MAINFRAME().

bool CVPCB_MAINFRAME::m_skipComponentSelect
protected
wxStaticText* CVPCB_MAINFRAME::m_statusLine1
private

Definition at line 69 of file cvpcb_mainframe.h.

Referenced by CVPCB_MAINFRAME(), and SetStatusText().

wxStaticText* CVPCB_MAINFRAME::m_statusLine2
private

Definition at line 70 of file cvpcb_mainframe.h.

Referenced by CVPCB_MAINFRAME(), and SetStatusText().

wxTextCtrl* CVPCB_MAINFRAME::m_tcFilterString
private

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