KiCad PCB EDA Suite
pcbnew/files.cpp File Reference
#include <confirm.h>
#include <core/arraydim.h>
#include <kicad_string.h>
#include <gestfich.h>
#include <pcb_edit_frame.h>
#include <3d_viewer/eda_3d_viewer.h>
#include <pgm_base.h>
#include <widgets/msgpanel.h>
#include <fp_lib_table.h>
#include <kiface_i.h>
#include <macros.h>
#include <trace_helpers.h>
#include <lockfile.cpp>
#include <netlist_reader/pcb_netlist.h>
#include <pcbnew_id.h>
#include <io_mgr.h>
#include <wildcards_and_files_ext.h>
#include <tool/tool_manager.h>
#include <board.h>
#include <wx/stdpaths.h>
#include <ratsnest/ratsnest_data.h>
#include <kiplatform/app.h>
#include <widgets/appearance_controls.h>
#include <widgets/infobar.h>
#include <settings/settings_manager.h>
#include <paths.h>
#include <project/project_file.h>
#include <project/project_local_settings.h>
#include <project/net_settings.h>
#include <plugins/cadstar/cadstar_pcb_archive_plugin.h>
#include <plugins/kicad/kicad_plugin.h>
#include <dialogs/dialog_imported_layers.h>
#include "footprint_info_impl.h"
#include <wx/wupdlock.h>
#include <wx/filedlg.h>

Go to the source code of this file.

Classes

class  CREATE_PROJECT_CHECKBOX
 

Macros

#define USE_INSTRUMENTATION   0
 

Functions

bool AskLoadBoardFileName (PCB_EDIT_FRAME *aParent, int *aCtl, wxString *aFileName, bool aKicadFilesOnly)
 Show a wxFileDialog asking for a BOARD filename to open. More...
 
bool AskSaveBoardFileName (PCB_EDIT_FRAME *aParent, wxString *aFileName, bool *aCreateProject)
 Put up a wxFileDialog asking for a BOARD filename to save. More...
 
IO_MGR::PCB_FILE_T plugin_type (const wxString &aFileName, int aCtl)
 

Macro Definition Documentation

◆ USE_INSTRUMENTATION

#define USE_INSTRUMENTATION   0

Definition at line 66 of file pcbnew/files.cpp.

Function Documentation

◆ AskLoadBoardFileName()

bool AskLoadBoardFileName ( PCB_EDIT_FRAME aParent,
int *  aCtl,
wxString *  aFileName,
bool  aKicadFilesOnly 
)

Show a wxFileDialog asking for a BOARD filename to open.

Parameters
aParentis a wxFrame passed to wxFileDialog.
aCtlis where to put the OpenProjectFiles() control bits.
aFileNameon entry is a probable choice, on return is the chosen filename.
aKicadFilesOnlytrue to list KiCad pcb files plugins only, false to list import plugins.
Returns
true if chosen, else false if user aborted.Helper widget to select whether a new project should be created for a file when saving

Definition at line 78 of file pcbnew/files.cpp.

References _, AddFileExtListToFilter(), IO_MGR::ALTIUM_CIRCUIT_MAKER, IO_MGR::ALTIUM_CIRCUIT_STUDIO, IO_MGR::ALTIUM_DESIGNER, AltiumCircuitMakerPcbFileWildcard(), AltiumCircuitStudioPcbFileWildcard(), AltiumDesignerPcbFileWildcard(), arrayDim(), IO_MGR::CADSTAR_PCB_ARCHIVE, CadstarPcbArchiveFileWildcard(), IO_MGR::EAGLE, EaglePcbFileWildcard(), IO_MGR::FABMASTER, FabmasterPcbFileWildcard(), filter, formatWildcardExt(), PATHS::GetDefaultUserProjectsPath(), EDA_BASE_FRAME::GetMruPath(), IO_MGR::KICAD_SEXP, KICTL_EAGLE_BRD, IO_MGR::LEGACY, LegacyPcbFileWildcard(), name, path, IO_MGR::PCAD, PCadPcbFileWildcard(), PcbFileWildcard(), IO_MGR::PluginFind(), and EDA_BASE_FRAME::SetMruPath().

Referenced by PCB_CONTROL::AppendBoardFromFile(), PCB_EDIT_FRAME::Files_io_from_id(), and PCB_EDIT_FRAME::OnFileHistory().

◆ AskSaveBoardFileName()

bool AskSaveBoardFileName ( PCB_EDIT_FRAME aParent,
wxString *  aFileName,
bool *  aCreateProject 
)

Put up a wxFileDialog asking for a BOARD filename to save.

Parameters
aParentis a wxFrame passed to wxFileDialog.
aFileNameon entry is a probable choice, on return is the chosen full filename (includes path).
aCreateProjectwill be filled with the state of the Create Project? checkbox if relevant.
Returns
true if chosen, else false if user aborted.

Definition at line 244 of file pcbnew/files.cpp.

245 {
246  wxString wildcard = PcbFileWildcard();
247  wxFileName fn = *aFileName;
248 
249  fn.SetExt( KiCadPcbFileExtension );
250 
251  wxFileDialog dlg( aParent, _( "Save Board File As" ), fn.GetPath(), fn.GetFullName(), wildcard,
252  wxFD_SAVE | wxFD_OVERWRITE_PROMPT );
253 
254  // Add a "Create a project" checkbox in standalone mode and one isn't loaded
255  if( Kiface().IsSingle() && aParent->Prj().IsNullProject() )
256  dlg.SetExtraControlCreator( &CREATE_PROJECT_CHECKBOX::Create );
257 
258  if( dlg.ShowModal() != wxID_OK )
259  return false;
260 
261  fn = dlg.GetPath();
262 
263  // always enforce filename extension, user may not have entered it.
264  fn.SetExt( KiCadPcbFileExtension );
265 
266  *aFileName = fn.GetFullPath();
267 
268  if( wxWindow* extraControl = dlg.GetExtraControl() )
269  *aCreateProject = static_cast<CREATE_PROJECT_CHECKBOX*>( extraControl )->GetValue();
270  else if( !aParent->Prj().IsNullProject() )
271  *aCreateProject = true;
272 
273  return true;
274 }
const std::string KiCadPcbFileExtension
bool IsSingle() const
Is this KIFACE_I running under single_top?
Definition: kiface_i.h:104
static wxWindow * Create(wxWindow *aParent)
PROJECT & Prj() const
Return a reference to the PROJECT associated with this KIWAY.
KIFACE_I & Kiface()
Global KIFACE_I "get" accessor.
virtual bool IsNullProject() const
Check if this project is a null project (i.e.
Definition: project.cpp:135
#define _(s)
Definition: 3d_actions.cpp:33
wxString PcbFileWildcard()

References _, CREATE_PROJECT_CHECKBOX::Create(), PROJECT::IsNullProject(), KIFACE_I::IsSingle(), KiCadPcbFileExtension, Kiface(), PcbFileWildcard(), and KIWAY_HOLDER::Prj().

Referenced by PCB_EDIT_FRAME::Files_io_from_id().

◆ plugin_type()

IO_MGR::PCB_FILE_T plugin_type ( const wxString &  aFileName,
int  aCtl 
)

Definition at line 460 of file pcbnew/files.cpp.

461 {
462  IO_MGR::PCB_FILE_T pluginType;
463 
464  wxFileName fn = aFileName;
465 
466  // Note: file extensions are expected to be in lower case.
467  // This is not always true, especially when importing files, so the string
468  // comparisons are case insensitive to try to find the suitable plugin.
469 
470  if( fn.GetExt().CmpNoCase( IO_MGR::GetFileExtension( IO_MGR::LEGACY ) ) == 0 )
471  {
472  // both legacy and eagle share a common file extension.
473  pluginType = ( aCtl & KICTL_EAGLE_BRD ) ? IO_MGR::EAGLE : IO_MGR::LEGACY;
474  }
475  else if( fn.GetExt().CmpNoCase( IO_MGR::GetFileExtension( IO_MGR::PCAD ) ) == 0 )
476  {
477  pluginType = IO_MGR::PCAD;
478  }
479  else if( fn.GetExt().CmpNoCase( IO_MGR::GetFileExtension( IO_MGR::ALTIUM_DESIGNER ) ) == 0 )
480  {
481  pluginType = IO_MGR::ALTIUM_DESIGNER;
482  }
483  else if( fn.GetExt().CmpNoCase( IO_MGR::GetFileExtension( IO_MGR::ALTIUM_CIRCUIT_STUDIO ) ) == 0 )
484  {
485  pluginType = IO_MGR::ALTIUM_CIRCUIT_STUDIO;
486  }
487  else if( fn.GetExt().CmpNoCase( IO_MGR::GetFileExtension( IO_MGR::ALTIUM_CIRCUIT_MAKER ) ) == 0 )
488  {
489  pluginType = IO_MGR::ALTIUM_CIRCUIT_MAKER;
490  }
491  else if( fn.GetExt().CmpNoCase( IO_MGR::GetFileExtension( IO_MGR::CADSTAR_PCB_ARCHIVE ) ) == 0 )
492  {
493  pluginType = IO_MGR::CADSTAR_PCB_ARCHIVE;
494  }
495  else if( fn.GetExt().CmpNoCase( IO_MGR::GetFileExtension( IO_MGR::FABMASTER ) ) == 0 )
496  {
497  pluginType = IO_MGR::FABMASTER;
498  }
499  else
500  {
501  pluginType = IO_MGR::KICAD_SEXP;
502  }
503 
504  return pluginType;
505 }
#define KICTL_EAGLE_BRD
chosen *.brd file is Eagle according to user.
Definition: kiway_player.h:78
Legacy Pcbnew file formats prior to s-expression.
Definition: io_mgr.h:54
PCB_FILE_T
The set of file types that the IO_MGR knows about, and for which there has been a plugin written.
Definition: io_mgr.h:52
S-expression Pcbnew file format.
Definition: io_mgr.h:55
static const wxString GetFileExtension(PCB_FILE_T aFileType)
Return the file extension for aFileType.
Definition: io_mgr.cpp:109

References IO_MGR::ALTIUM_CIRCUIT_MAKER, IO_MGR::ALTIUM_CIRCUIT_STUDIO, IO_MGR::ALTIUM_DESIGNER, IO_MGR::CADSTAR_PCB_ARCHIVE, IO_MGR::EAGLE, IO_MGR::FABMASTER, IO_MGR::GetFileExtension(), IO_MGR::KICAD_SEXP, KICTL_EAGLE_BRD, IO_MGR::LEGACY, and IO_MGR::PCAD.

Referenced by PCB_CONTROL::AppendBoardFromFile(), and PCB_EDIT_FRAME::OpenProjectFiles().