91#include <wx/stdpaths.h>
94#include <wx/filedlg.h>
95#include <wx/txtstrm.h>
96#include <wx/wfstream.h>
97#include <wx/zipstrm.h>
103#define USE_INSTRUMENTATION 0
118 std::vector<IO_BASE::IO_FILE_DESC> descriptions;
131 wxCHECK( pi,
false );
138 descriptions.emplace_back( desc );
141 wxString fileFiltersStr;
142 std::vector<std::string> allExtensions;
143 std::set<wxString> allWildcardsSet;
147 if( !fileFiltersStr.IsEmpty() )
148 fileFiltersStr += wxChar(
'|' );
150 fileFiltersStr += desc.FileFilter();
152 for(
const std::string& ext : desc.m_FileExtensions )
154 allExtensions.emplace_back( ext );
159 wxString allWildcardsStr;
161 for(
const wxString& wildcard : allWildcardsSet )
162 allWildcardsStr << wildcard;
170 fileFiltersStr =
_(
"All supported formats" ) + wxT(
"|" ) + allWildcardsStr + wxT(
"|" )
174 wxFileName fileName( *aFileName );
178 if( fileName.FileExists() )
180 path = fileName.GetPath();
181 name = fileName.GetFullName();
194 wxFileDialog dlg( aParent, kicadFormat ?
_(
"Open Board File" ) :
_(
"Import Non KiCad Board File" ),
195 path,
name, fileFiltersStr, wxFD_OPEN | wxFD_FILE_MUST_EXIST );
200 dlg.SetCustomizeHook( importOptions );
204 if( dlg.ShowModal() == wxID_OK )
206 *aFileName = dlg.GetPath();
207 aParent->
SetMruPath( wxFileName( dlg.GetPath() ).GetPath() );
233 wxFileName fn = *aFileName;
237 wxFileDialog dlg( aParent,
_(
"Save Board File As" ), fn.GetPath(), fn.GetFullName(), wildcard,
238 wxFD_SAVE | wxFD_OVERWRITE_PROMPT );
244 dlg.SetCustomizeHook( newProjectHook );
248 if( dlg.ShowModal() != wxID_OK )
251 *aFileName = dlg.GetPath();
257 *aCreateProject =
true;
267 if( !filename.IsEmpty() )
269 if( !wxFileName::IsFileReadable( filename ) )
289 if( !
Kiface().IsSingle() )
293 wxString fileName =
m_frame->Prj().AbsolutePath(
m_frame->GetBoard()->GetFileName() );
296 m_frame->OpenProjectFiles( std::vector<wxString>( 1, fileName ), open_ctl );
309 m_frame->OpenProjectFiles( std::vector<wxString>( 1, fileName ), open_ctl );
317 wxFileName fn =
m_frame->Prj().AbsolutePath(
m_frame->GetBoard()->GetFileName() );
319 if( !
IsOK(
m_frame, wxString::Format(
_(
"Revert '%s' to last version saved?" ), fn.GetFullPath() ) ) )
322 return m_frame->ReloadFromDisk();
329 if( !
Kiface().IsSingle() )
332 if( !
m_frame->CloseFootprintFieldsTableDialog() )
335 if(
m_frame->IsContentModified() )
337 wxFileName fileName =
m_frame->GetBoard()->GetFileName();
338 wxString saveMsg =
_(
"Current board will be closed, save changes to '%s' before "
344 return m_frame->SaveBoard();
350 else if( !
m_frame->GetBoard()->IsEmpty() )
352 if( !
IsOK(
m_frame,
_(
"Current Board will be closed. Continue?" ) ) )
356 m_frame->SaveProjectLocalSettings();
358 m_frame->GetBoard()->ClearProject();
361 if( !
m_frame->Clear_Pcb(
false ) )
364 m_frame->LoadProjectSettings();
378 if( !
GetBoard()->GetFileName().IsEmpty() )
392 wxFileName::SplitPath(
GetBoard()->GetFileName(),
nullptr,
nullptr, &orig_name,
nullptr );
394 if( orig_name.IsEmpty() )
397 wxFileName savePath(
Prj().GetProjectFullName() );
399 if( !savePath.IsOk() || !savePath.IsDirWritable() )
403 if( !savePath.IsOk() || !savePath.IsDirWritable() )
408 wxString filename = fn.GetFullPath();
409 bool createProject =
false;
410 bool success =
false;
420 success =
SavePcbFile( filename, aSaveAs, createProject );
441 for(
int i = 0; i < collector.
GetCount(); i++ )
445 int itemWidth =
static_cast<PCB_SHAPE*
>( collector[i] )->GetWidth();
447 if( edgeWidth != -1 && edgeWidth != itemWidth )
450 edgeWidth = std::max( edgeWidth, itemWidth );
454 edgeWidth = itemWidth;
459 if( mixed && aShowUserMsg )
463 _(
"If the zones on this board are refilled the Copper Edge "
464 "Clearance setting will be used (see Board Setup > Design "
465 "Rules > Constraints).\n This may result in different fills "
466 "from previous KiCad versions which used the line thicknesses "
467 "of the board boundary on the Edge Cuts layer." ) );
470 return std::max( 0, edgeWidth / 2 );
478 if( fileName.IsEmpty() )
493 if( aFileSet.size() != 1 )
495 DisplayError(
this, wxString::Format(
"Pcbnew:%s() takes a single filename", __func__ ) );
499 wxString fullFileName( aFileSet[0] );
500 wxFileName wx_filename( fullFileName );
507 wxASSERT_MSG( wx_filename.IsAbsolute(), wxT(
"Path is not absolute!" ) );
509 std::unique_ptr<LOCKFILE> lock = std::make_unique<LOCKFILE>( fullFileName );
514 if(
Prj().IsLockOverrideGranted() )
516 lock->OverrideLock();
520 msg.Printf(
_(
"PCB '%s' is already open by '%s' at '%s'." ),
521 wx_filename.GetFullName(),
523 lock->GetHostname() );
528 lock->OverrideLock();
547 wxFileName pro = fullFileName;
550 bool is_new = !wxFileName::IsFileReadable( fullFileName );
558 msg.Printf(
_(
"PCB '%s' does not exist. Do you wish to create it?" ), fullFileName );
560 if( !
IsOK(
this, msg ) )
569 statusBar->ClearWarningMessages(
"load" );
585 progressReporter.Hide();
636 wxString importedRules;
649 BOARD* loadedBoard =
nullptr;
650 bool failedLoad =
false;
653 std::vector<std::unique_ptr<FOOTPRINT>> importedLibFootprints;
657 std::map<std::string, UTF8> props;
666#if USE_INSTRUMENTATION
674 ?
static_cast<REPORTER*
>( &loadReporter )
681 importedRules = aPlugin.GetImportedDesignRules();
688 for(
FOOTPRINT* fp : aPlugin.GetImportedCachedLibraryFootprints() )
689 importedLibFootprints.emplace_back( fp );
705 const auto layerMapCallback =
706 [
this](
const std::vector<INPUT_LAYER_DESC>& aLayers )
711 mappable_pi->RegisterCallback( layerMapCallback );
718 const auto chooseProjectCallback =
719 [
this](
const std::vector<IMPORT_PROJECT_DESC>& aProjects )
724 chooser_pi->RegisterCallback( chooseProjectCallback );
727 aPlugin.SetQueryUserCallback(
728 [&]( wxString aTitle,
int aIcon, wxString aMessage, wxString aAction ) ->
bool
730 KIDIALOG dlg(
nullptr, aMessage, aTitle, wxOK | wxCANCEL | aIcon );
732 if( !aAction.IsEmpty() )
733 dlg.SetOKLabel( aAction );
741 std::unique_ptr<BOARD> loaded =
BOARD_LOADER::Load( fullFileName, pluginType, &
Prj(), loaderOptions );
745 std::optional<std::map<wxString, wxString>> netNames =
752 THROW_IO_ERROR(
_(
"Cannot apply imported net-name map to the board." ) );
755 loadedBoard = loaded.release();
757#if USE_INSTRUMENTATION
759 printf(
"PCB_IO::Load(): %u usecs\n", stopTime - startTime );
764 msg.Printf(
_(
"Error loading PCB '%s'." ), fullFileName );
765 progressReporter.Hide();
777 msg.Printf(
_(
"Error loading PCB '%s'." ), fullFileName );
778 progressReporter.Hide();
783 catch(
const std::bad_alloc& )
785 msg.Printf(
_(
"Memory exhausted loading PCB '%s'" ), fullFileName );
786 progressReporter.Hide();
792 if( failedLoad || !loadedBoard )
799 statusBar->AddWarningMessages(
"load", loadReporter.
GetMessages() );
821 SetBoard( loadedBoard,
false, &progressReporter );
823 postLoadTimer.
msecs(
true ) );
862 m_infoBar->ShowMessage(
_(
"Could not load component class assignment rules" ),
863 wxICON_WARNING, WX_INFOBAR::MESSAGE_TYPE::GENERIC );
869 postLoadTimer.
msecs(
true ) );
875 postLoadTimer.
msecs(
true ) );
881 postLoadTimer.
msecs(
true ) );
893 && loadedBoard->
GetGenerator().Lower() != wxT(
"gerbview" ) ) )
897 m_infoBar->ShowMessage(
_(
"This file was created by an older version of KiCad. "
898 "It will be converted to the new format when saved." ),
899 wxICON_WARNING, WX_INFOBAR::MESSAGE_TYPE::OUTDATED_SAVE );
912 fname = previousBoardFileName;
918 fn.SetPath(
Prj().GetProjectPath() );
919 fn.SetName(
Prj().GetProjectName() );
922 fname = fn.GetFullPath();
938 std::vector<ZONE*> toFill;
943 wxLogTrace(
traceAllegroPerf, wxT(
"Post-load BuildConnectivity: %.3f ms" ),
944 connectivityTimer.
msecs(
true ) );
949 wxLogTrace(
traceAllegroPerf, wxT(
"Post-load LoadProjectSettings+DrawingSheet: %.3f ms" ),
950 connectivityTimer.
msecs(
true ) );
960 wxLogTrace(
traceAllegroPerf, wxT(
"Post-load DRC+ComponentClass+Tuning caches: %.3f ms" ),
961 connectivityTimer.
msecs(
true ) );
966 connectivityTimer.
msecs(
true ) );
967 wxLogTrace(
traceAllegroPerf, wxT(
"=== Post-load pipeline total: %.3f ms ===" ),
968 connectivityTimer.
msecs() );
972 our3DViewer->NewDisplay();
974#if 0 && defined(DEBUG)
997 statusBar->AddWarningMessages(
"load", loadReporter.
GetMessages() );
1007 bool aChangeProject )
1010 wxFileName pcbFileName = aFileName;
1020 wxString msg = wxString::Format(
_(
"Insufficient permissions to write file '%s'." ),
1021 pcbFileName.GetFullPath() );
1028 wxFileName projectFile( pcbFileName );
1029 wxFileName rulesFile( pcbFileName );
1035 if( projectFile.FileExists() )
1039 else if( aChangeProject )
1045 wxFileName currentRules(
GetBoard()->GetDesignRulesPath() );
1047 if( currentRules.FileExists() && !rulesFile.FileExists() && aChangeProject )
1048 KiCopyFile( currentRules.GetFullPath(), rulesFile.GetFullPath(), msg );
1050 if( !msg.IsEmpty() )
1052 DisplayError(
this, wxString::Format(
_(
"Error saving custom rules file '%s'." ),
1053 rulesFile.GetFullPath() ) );
1056 if( projectFile.FileExists() )
1072 if( pcbFileName.FileExists() )
1079 pi->SaveBoard( pcbFileName.GetFullPath(), *
GetBoard(),
nullptr );
1083 DisplayError(
this, wxString::Format(
_(
"Error saving board file '%s'.\n%s" ),
1084 pcbFileName.GetFullPath(),
1091 if( !
Kiface().IsSingle() )
1097 LockFile( pcbFileName.GetFullPath() );
1103 lowerTxt.Printf(
_(
"File '%s' saved." ), pcbFileName.GetFullPath() );
1105 SetStatusText( lowerTxt, 0 );
1108 if(
m_infoBar->GetMessageType() == WX_INFOBAR::MESSAGE_TYPE::OUTDATED_SAVE )
1116 wxString backupMsg = backupReporter.
GetMessages();
1117 m_infoBar->ShowMessageFor( backupMsg.Trim(), 10000, wxICON_WARNING );
1127 if( !
Prj().IsNullProject() )
1152 wxFileName pcbFileName( aFileName );
1158 DisplayError(
this, wxString::Format(
_(
"Insufficient permissions to write file '%s'." ),
1159 pcbFileName.GetFullPath() ) );
1174 if( pcbFileName.FileExists() )
1181 wxASSERT( pcbFileName.IsAbsolute() );
1183 pi->SaveBoard( pcbFileName.GetFullPath(), *
GetBoard(),
nullptr );
1189 DisplayError(
this, wxString::Format(
_(
"Error saving board file '%s'.\n%s" ),
1190 pcbFileName.GetFullPath(),
1197 wxFileName projectFile( pcbFileName );
1198 wxFileName rulesFile( pcbFileName );
1204 if( aCreateProject && !projectFile.FileExists() )
1207 wxFileName currentRules(
GetBoard()->GetDesignRulesPath() );
1209 if( aCreateProject && currentRules.FileExists() && !rulesFile.FileExists() )
1210 KiCopyFile( currentRules.GetFullPath(), rulesFile.GetFullPath(), msg );
1212 if( !msg.IsEmpty() && !aHeadless )
1214 DisplayError(
this, wxString::Format(
_(
"Error saving custom rules file '%s'." ),
1215 rulesFile.GetFullPath() ) );
1223 const std::map<std::string, UTF8>* aProperties )
1262 std::vector<std::unique_ptr<FOOTPRINT>> aDefinitions,
const wxString& aBoardPath )
1272 statusBar->AddWarningMessages(
"load",
reporter.GetMessages() );
static const ADVANCED_CFG & GetCfg()
Get the singleton instance's config, which is shared by all consumers.
void SetContentModified(bool aModified=true)
int m_CopperEdgeClearance
int GenerateODBPPFiles(const TOOL_EVENT &aEvent)
int New(const TOOL_EVENT &aEvent)
int Revert(const TOOL_EVENT &aEvent)
int GenIPC2581File(const TOOL_EVENT &aEvent)
int Open(const TOOL_EVENT &aEvent)
int OpenNonKicadBoard(const TOOL_EVENT &aEvent)
static std::unique_ptr< BOARD > Load(const wxString &aFileName, PCB_IO_MGR::PCB_FILE_T aFormat, PROJECT *aProject, const OPTIONS &aOptions)
Information pertinent to a Pcbnew printed circuit board.
bool m_LegacyDesignSettingsLoaded
True if the legacy board design settings were loaded from a file.
GAL_SET m_LegacyVisibleItems
LENGTH_DELAY_CALCULATION * GetLengthCalculation() const
Returns the track length calculator.
void SetFileName(const wxString &aFileName)
bool BuildConnectivity(PROGRESS_REPORTER *aReporter=nullptr)
Build or rebuild the board connectivity database for the board, especially the list of connected item...
void SynchronizeNetsAndNetClasses(bool aResetTrackAndViaSizes)
Copy NETCLASS info to each NET, based on NET membership in a NETCLASS.
bool SetLayerName(PCB_LAYER_ID aLayer, const wxString &aLayerName)
Changes the name of the layer given by aLayer.
LSET m_LegacyVisibleLayers
Visibility settings stored in board prior to 6.0, only used for loading legacy files.
void SetProject(PROJECT *aProject, bool aReferenceOnly=false)
Link a board to a given project.
const wxString & GetFileName() const
int GetFileFormatVersionAtLoad() const
const wxString & GetGenerator() const
const LSET & GetEnabledLayers() const
A proxy function that calls the corresponding function in m_BoardSettings.
void SynchronizeProperties()
Copy the current project's text variables into the boards property cache.
COMPONENT_CLASS_MANAGER & GetComponentClassManager()
Gets the component class manager.
bool SynchronizeComponentClasses(const std::unordered_set< wxString > &aNewSheetPaths) const
Copy component class / component class generator information from the project settings.
bool m_LegacyCopperEdgeClearanceLoaded
BOARD_DESIGN_SETTINGS & GetDesignSettings()
int GetCount() const
Return the number of objects in the list.
void RebuildRequiredCaches(FOOTPRINT *aFootprint=nullptr) const
Rebuilds any caches that may be required by custom assignment rules.
static std::vector< IMPORT_PROJECT_DESC > RunModal(wxWindow *aParent, const std::vector< IMPORT_PROJECT_DESC > &aProjectDesc)
Create and show a dialog (modal) and returns the data from it after completion.
static std::map< wxString, PCB_LAYER_ID > RunModal(wxWindow *aParent, const std::vector< INPUT_LAYER_DESC > &aLayerDesc)
Create and show a dialog (modal) and returns the data from it after completion.
Create and handle a window for the 3d viewer connected to a Kiway and a pcbboard.
virtual APP_SETTINGS_BASE * config() const
Return the settings object used in SaveSettings(), and is overloaded in KICAD_MANAGER_FRAME.
void CheckForAutosaveFiles(const wxString &aProjectPath, const std::vector< wxString > &aExtensions)
Check for autosave files newer than their source files for the given project.
SETTINGS_MANAGER * GetSettingsManager() const
wxTimer * m_autoSaveTimer
void UpdateFileHistory(const wxString &FullFileName, FILE_HISTORY *aFileHistory=nullptr)
Update the list of recently opened files.
wxString GetMruPath() const
bool IsWritable(const wxFileName &aFileName, bool aVerbose=true)
Check if aFileName can be written.
virtual void ClearFileHistory()
Remove all files from the file history.
wxString GetFileFromHistory(int cmdId, const wxString &type, FILE_HISTORY *aFileHistory=nullptr)
Fetch the file name from the file history list.
void SetMruPath(const wxString &aPath)
WX_INFOBAR * GetInfoBar()
void ReleaseFile()
Release the current file marked in use.
std::unique_ptr< LOCKFILE > m_file_checker
Prevents opening same file multiple times.
bool LockFile(const wxString &aFileName)
Mark a schematic file as being in use.
void RefreshGitCommitPane()
Attach the git session if needed and refresh the version-control pane, when it is shown.
bool GetCreateNewProject() const
Gets the selected state of the create new project option.
bool IsAttachedToDialog() const
Gets if this hook has attached controls to a dialog box.
bool GetShowIssues() const
static const std::vector< KICAD_T > AllBoardItems
A scan list for all editable board items.
An exception saying that the user cancelled an interactive part of a load, import,...
Hold an error message and may be used when throwing exceptions containing meaningful error messages.
virtual const wxString What() const
A composite of Problem() and Where()
virtual const wxString Problem() const
what was the problem?
Helper class to create more flexible dialogs, including 'do not show again' checkbox handling.
void DoNotShowCheckbox(wxString file, int line)
Shows the 'do not show again' checkbox.
KISTATUSBAR is a wxStatusBar suitable for Kicad manager.
PROJECT & Prj() const
Return a reference to the PROJECT associated with this KIWAY.
LOCAL_HISTORY & LocalHistory()
Return the LOCAL_HISTORY associated with this KIWAY.
Plugin class for import plugins that support remappable layers.
void SynchronizeTuningProfileProperties() const
Ensure time domain properties provider is synced with board / project settings if required.
bool RunRegisteredSaversAndCommit(const wxString &aProjectPath, const wxString &aTitle, const wxString &aTagFileType=wxEmptyString)
Run all registered savers and, if any staged changes differ from HEAD, create a commit.
void RemoveAutosaveFiles(const wxString &aProjectPath) const
Remove every autosave file under the project at aProjectPath regardless of which source it shadowed.
LSEQ Seq(const LSEQ &aSequence) const
Return an LSEQ from the union of this LSET and a desired sequence.
static REPORTER & GetInstance()
static wxString GetDefaultUserProjectsPath()
Gets the default path we point users to create projects.
static TOOL_ACTION repairBoard
static TOOL_ACTION rehatchShapes
const VECTOR2I GetPageSizeIU() const override
Works off of GetPageSettings() to return the size of the paper page in the internal units of this par...
PCBNEW_SETTINGS * GetPcbNewSettings() const
PCB_DRAW_PANEL_GAL * GetCanvas() const override
Return a pointer to GAL-based canvas of given EDA draw frame.
PCB_SCREEN * GetScreen() const override
Return a pointer to a BASE_SCREEN or one of its derivatives.
EDA_3D_VIEWER_FRAME * GetOur3DViewerFrame()
virtual void UpdateStatusBar() override
Update the status bar information.
The main frame for Pcbnew.
void LoadDrawingSheet()
Load the drawing sheet file.
void ResolveDRCExclusions(bool aCreateMarkers)
If aCreateMarkers then create DRC exclusion markers from the serialized data.
void SetBoard(BOARD *aBoard, PROGRESS_REPORTER *aReporter=nullptr) override
Set the m_pcb member in such as way as to ensure deleting any previous BOARD.
void OnModify() override
Must be called after a board change to set the modified flag.
bool CloseFootprintFieldsTableDialog()
bool ReloadFromDisk()
Reload the board from disk.
void OnClearFileHistory(wxCommandEvent &aEvent)
bool SaveBoard(bool aSaveAs=false, bool aSaveCopy=false)
bool OpenProjectFiles(const std::vector< wxString > &aFileSet, int aCtl=0) override
Load a KiCad board (.kicad_pcb) from aFileName.
void ProjectChanged() override
Notification event that the project has changed.
WX_INFOBAR * m_loadNoticeInfoBar
Secondary infobar that stacks above the main one; reserved for load-time notices (currently the WRL -...
void SaveProjectLocalSettings() override
Save changes to the project local settings.
bool SavePcbCopy(const wxString &aFileName, bool aCreateProject=false, bool aHeadless=false)
Write the board data structures to aFileName.
bool IsContentModified() const override
Get if the current board has been modified but not saved.
bool LoadProjectSettings()
Load the current project's file configuration settings which are pertinent to this PCB_EDIT_FRAME ins...
bool Clear_Pcb(bool doAskAboutUnsavedChanges, bool aFinal=false)
Delete all and reinitialize the current board.
void OnBoardLoaded()
Update the state of the GUI after a new board is loaded or created.
void UpdateTitle()
Set the main window title bar text.
int inferLegacyEdgeClearance(BOARD *aBoard, bool aShowUserMsg=true)
const std::map< std::string, UTF8 > * m_importProperties
void reconcileImportedFootprintLibraries(std::vector< std::unique_ptr< FOOTPRINT > > aDefinitions, const wxString &aBoardPath)
Reconcile the footprint-library references of a freshly imported non-KiCad board so that every board ...
bool SavePcbFile(const wxString &aFileName, bool addToHistory=true, bool aChangeProject=true)
Write the board data structures to a aFileName.
bool importFile(const wxString &aFileName, int aFileType, const std::map< std::string, UTF8 > *aProperties=nullptr)
Load the given filename but sets the path to the current project path.
void saveProjectSettings() override
Save any design-related project settings associated with this frame.
void OnFileHistory(wxCommandEvent &event)
static PLUGIN_REGISTRY * Instance()
PCB_FILE_T
The set of file types that the PCB_IO_MGR knows about, and for which there has been a plugin written,...
@ KICAD_SEXP
S-expression Pcbnew file format.
@ TARGET3001
TARGET 3001! project.
@ GEDA_PCB
Geda PCB file formats.
@ LEGACY
Legacy Pcbnew file formats prior to s-expression.
static PCB_IO * FindPlugin(PCB_FILE_T aFileType)
Return a PCB_IO which the caller can use to import, export, save, or load design documents.
static PCB_FILE_T FindPluginTypeFromBoardPath(const wxString &aFileName, int aCtl=0)
Return a plugin type given a path for a board file.
static bool ImportGeneratesProjectLibrary(PCB_FILE_T aFileType)
Return true when importing aFileType should materialize a project footprint library.
A base class that BOARD loading and saving plugins should derive from.
Collect all BOARD_ITEM objects on a given layer.
void Collect(BOARD_ITEM *aBoard, const std::vector< KICAD_T > &aTypes)
Test a BOARD_ITEM using this class's Inspector method, which does the collection.
void SetLayerId(PCB_LAYER_ID aLayerId)
void PreloadDesignBlockLibraries(KIWAY *aKiway)
Starts a background job to preload the global and project design block libraries.
A small class to help profiling.
double msecs(bool aSinceLast=false)
virtual void AdvancePhase() override
Use the next available virtual zone of the dialog progress bar.
void AddPhases(int aNumPhases) override
bool KeepRefreshing(bool aWait=false) override
Update the UI dialog.
Plugin class for import plugins that support choosing a project.
LSET m_VisibleLayers
Board settings.
GAL_SET m_VisibleItems
The GAL layers (aka items) that are turned on for viewing (.
virtual void SetReadOnly(bool aReadOnly=true)
virtual const wxString GetProjectFullName() const
Return the full path and name of the project.
virtual PROJECT_LOCAL_SETTINGS & GetLocalSettings() const
virtual const wxString AbsolutePath(const wxString &aFileName) const
Fix up aFileName if it is relative to the project's directory to be an absolute path and filename.
virtual bool IsNullProject() const
Check if this project is a null project (i.e.
A pure virtual class used to derive REPORTER objects from.
virtual bool HasMessage() const
Returns true if any messages were reported.
void SaveProjectAs(const wxString &aFullPath, PROJECT *aProject=nullptr)
Set the currently loaded project path and saves it (pointers remain valid).
bool SaveProject(const wxString &aFullPath=wxEmptyString, PROJECT *aProject=nullptr)
Save a loaded project.
bool SaveProjectCopy(const wxString &aFullPath, PROJECT *aProject=nullptr)
Save a copy of the current project under the given path.
bool UnloadProject(PROJECT *aProject, bool aSave=true)
Save, unload and unregister the given PROJECT.
bool TriggerBackupIfNeeded(REPORTER &aReporter) const
Call BackupProject() if a new backup is needed according to the current backup policy.
PROJECT & Prj() const
A helper while we are not MDI-capable – return the one and only project.
bool LoadProject(const wxString &aFullPath, bool aSetActive=true, bool aOverrideLock=false)
Load a project or sets up a new project with a specified path.
static void ResolvePossibleSymlinks(wxFileName &aFilename)
void Dismiss() override
Dismisses the infobar and updates the containing layout and AUI manager (if one is provided).
Multi-thread safe progress reporter dialog, intended for use of tasks that parallel reporting back of...
A wrapper for reporting to a wxString object.
const wxString & GetMessages() const
wxString EnsureFileExtension(const wxString &aFilename, const wxString &aExtension)
It's annoying to throw up nag dialogs when the extension isn't right.
bool AskOverrideLock(wxWindow *aParent, const wxString &aMessage)
Display a dialog indicating the file is already open, with an option to reset the lock.
bool IsOK(wxWindow *aParent, const wxString &aMessage)
Display a yes/no dialog with aMessage and returns the user response.
void DisplayInfoMessage(wxWindow *aParent, const wxString &aMessage, const wxString &aExtraInfo)
Display an informational message box with aMessage.
bool HandleUnsavedChanges(wxWindow *aParent, const wxString &aMessage, const std::function< bool()> &aSaveFunction)
Display a dialog with Save, Cancel and Discard Changes buttons.
void DisplayErrorMessage(wxWindow *aParent, const wxString &aText, const wxString &aExtraInfo)
Display an error message with aMessage.
void DisplayError(wxWindow *aParent, const wxString &aText)
Display an error or warning message box with aMessage.
This file is part of the common library.
KIFACE_BASE & Kiface()
Global KIFACE_BASE "get" accessor.
Declaration of the eda_3d_viewer class.
int RefreshGeneratedTables(BOARD &aBoard)
Bring every generated table on the board up to date and return how many were rebuilt.
void KiCopyFile(const wxString &aSrcPath, const wxString &aDestPath, wxString &aErrors)
#define WIN_STRING_DIR_SEP
#define UNIX_STRING_DIR_SEP
#define THROW_IO_ERROR(msg)
macro which captures the "call site" values of FILE_, __FUNCTION & LINE
static const std::string ProjectFileExtension
static const std::string LegacyPcbFileExtension
static const std::string DesignRulesFileExtension
static const std::string KiCadPcbFileExtension
static wxString PcbFileWildcard()
bool SaveImportedDesignRules(const wxString &aRules, const wxFileName &aBoardPath, REPORTER &aReporter)
Save the custom rules an importer derived beside the board it produced.
bool ApplyImportedNetNameMap(BOARD &aBoard, const std::map< wxString, wxString > &aNames, REPORTER &aReporter)
Apply caller-selected imported net names without changing net identity or connectivity.
std::unique_ptr< T > IO_RELEASER
Helper to hold and release an IO_BASE object when exceptions are thrown.
#define KICTL_CREATE
caller thinks requested project files may not exist.
#define KICTL_REVERT
reverting to a previously-saved (KiCad) file.
#define KICTL_IMPORT_LIB
import all footprints into a project library.
#define KICTL_KICAD_ONLY
chosen file is from KiCad according to user
#define KICTL_NONKICAD_ONLY
chosen file is non-KiCad according to user
@ GAL_LAYER_ID_BITMASK_END
This is the end of the layers used for visibility bit masks in legacy board files.
PCB_LAYER_ID
A quick note on layer IDs:
#define GAL_LAYER_INDEX(x)
Use this macro to convert a GAL layer to a 0-indexed offset from LAYER_VIAS.
This file contains miscellaneous commonly used macros and functions.
std::optional< std::map< wxString, wxString > > SplitNetNameMap(const wxString &aValue)
Decode a net-name map property value, or nothing when the value is not one.
constexpr char NET_NAME_MAP[]
#define SEXPR_BOARD_FILE_VERSION
Current s-expression file format version. 2 was the last legacy format version.
bool AskLoadBoardFileName(PCB_EDIT_FRAME *aParent, wxString *aFileName, int aCtl=0)
Show a wxFileDialog asking for a BOARD filename to open.
bool AskSaveBoardFileName(PCB_EDIT_FRAME *aParent, wxString *aFileName, bool *aCreateProject)
Put up a wxFileDialog asking for a BOARD filename to save.
static const wxChar *const traceAllegroPerf
PGM_BASE & Pgm()
The global program "get" accessor.
int64_t GetRunningMicroSecs()
An alternate way to calculate an elapsed time (in microsecondes) to class PROF_COUNTER.
#define NAMELESS_PROJECT
default name for nameless projects
KIWAY Kiway(KFCTL_STANDALONE)
MODEL3D_FORMAT_TYPE fileType(const char *aFileName)
bool show_import_issues
Stored value for "show import issues" when importing non-KiCad designs to this application.
bool initialize_after_load
std::function< void(PCB_IO &)> plugin_configurator
std::function< void(PCB_IO &)> post_load_hook
const std::map< std::string, UTF8 > * properties
PROGRESS_REPORTER * progress_reporter
Container that describes file type info.
std::vector< std::string > m_FileExtensions
Filter used for file pickers if m_IsFile is true.
bool m_CanRead
Whether the IO can read this file type.
virtual void PreloadLibraries(KIWAY *aKiway)
IbisParser parser & reporter
wxLogTrace helper definitions.
@ PCB_SHAPE_T
class PCB_SHAPE, a segment not on copper layers
wxString AddFileExtListToFilter(const std::vector< std::string > &aExts)
Build the wildcard extension file dialog wildcard filter to add to the base message dialog.
wxString formatWildcardExt(const wxString &aWildcard)
Format wildcard extension to support case sensitive file dialogs.
Definition of file extensions used in Kicad.