43#include <wx/snglinst.h>
78#include <wx/stdpaths.h>
80#include <wx/filedlg.h>
81#include <wx/txtstrm.h>
82#include <wx/wfstream.h>
83#include <wx/zipstrm.h>
85#include "widgets/filedlg_hook_save_project.h"
88#define USE_INSTRUMENTATION 0
102 std::vector<IO_BASE::IO_FILE_DESC> descriptions;
115 wxCHECK( pi,
false );
122 descriptions.emplace_back( desc );
125 wxString fileFiltersStr;
126 std::vector<std::string> allExtensions;
127 std::set<wxString> allWildcardsSet;
131 if( !fileFiltersStr.IsEmpty() )
132 fileFiltersStr += wxChar(
'|' );
134 fileFiltersStr += desc.FileFilter();
136 for(
const std::string& ext : desc.m_FileExtensions )
138 allExtensions.emplace_back( ext );
143 wxString allWildcardsStr;
145 for(
const wxString& wildcard : allWildcardsSet )
146 allWildcardsStr << wildcard;
154 fileFiltersStr =
_(
"All supported formats" ) + wxT(
"|" ) + allWildcardsStr + wxT(
"|" )
158 wxFileName fileName( *aFileName );
162 if( fileName.FileExists() )
164 path = fileName.GetPath();
165 name = fileName.GetFullName();
178 wxFileDialog dlg( aParent,
179 kicadFormat ?
_(
"Open Board File" ) :
_(
"Import Non KiCad Board File" ),
180 path,
name, fileFiltersStr, wxFD_OPEN | wxFD_FILE_MUST_EXIST );
185 dlg.SetCustomizeHook( importOptions );
187 if( dlg.ShowModal() == wxID_OK )
189 *aFileName = dlg.GetPath();
190 aParent->
SetMruPath( wxFileName( dlg.GetPath() ).GetPath() );
216 wxFileName fn = *aFileName;
220 wxFileDialog dlg( aParent,
_(
"Save Board File As" ), fn.GetPath(), fn.GetFullName(), wildcard,
221 wxFD_SAVE | wxFD_OVERWRITE_PROMPT );
227 dlg.SetCustomizeHook( newProjectHook );
229 if( dlg.ShowModal() != wxID_OK )
232 *aFileName = dlg.GetPath();
238 *aCreateProject =
true;
250 if( !wxFileName::IsFileReadable( fn ) )
269 int id =
event.GetId();
283 if( !
Kiface().IsSingle() )
306 wxFileName fn = currfn;
309 fn.SetName( rec_name );
311 if( !fn.FileExists() )
313 msg.Printf(
_(
"Recovery file '%s' not found." ), fn.GetFullPath() );
318 msg.Printf(
_(
"OK to load recovery file '%s'?" ), fn.GetFullPath() );
320 if( !
IsOK(
this, msg ) )
340 msg.Printf(
_(
"Revert '%s' to last version saved?" ), fn.GetFullPath() );
342 if( !
IsOK(
this, msg ) )
355 if( !
Kiface().IsSingle() )
361 wxString saveMsg =
_(
"Current board will be closed, save changes to '%s' before "
367 return Files_io_from_id( ID_SAVE_BOARD );
375 if( !
IsOK(
this,
_(
"Current Board will be closed. Continue?" ) ) )
399 if( !
GetBoard()->GetFileName().IsEmpty() )
418 wxFileName::SplitPath(
GetBoard()->GetFileName(),
nullptr,
nullptr, &orig_name,
nullptr );
420 if( orig_name.IsEmpty() )
423 wxFileName savePath(
Prj().GetProjectFullName() );
425 if( !savePath.IsOk() || !savePath.IsDirWritable() )
429 if( !savePath.IsOk() || !savePath.IsDirWritable() )
434 wxString filename = fn.GetFullPath();
435 bool createProject =
false;
436 bool success =
false;
446 success =
SavePcbFile( filename, addToHistory, createProject );
472 for(
int i = 0; i < collector.
GetCount(); i++ )
476 int itemWidth =
static_cast<PCB_SHAPE*
>( collector[i] )->GetWidth();
478 if( edgeWidth != -1 && edgeWidth != itemWidth )
481 edgeWidth = std::max( edgeWidth, itemWidth );
485 edgeWidth = itemWidth;
490 if( mixed && aShowUserMsg )
494 _(
"If the zones on this board are refilled the Copper Edge "
495 "Clearance setting will be used (see Board Setup > Design "
496 "Rules > Constraints).\n This may result in different fills "
497 "from previous KiCad versions which used the line thicknesses "
498 "of the board boundary on the Edge Cuts layer." ) );
501 return std::max( 0, edgeWidth / 2 );
508 if( aFileSet.size() != 1 )
510 UTF8 msg =
StrPrintf(
"Pcbnew:%s() takes a single filename", __func__ );
515 wxString fullFileName( aFileSet[0] );
516 wxFileName wx_filename( fullFileName );
523 wxASSERT_MSG( wx_filename.IsAbsolute(), wxT(
"Path is not absolute!" ) );
525 std::unique_ptr<LOCKFILE> lock = std::make_unique<LOCKFILE>( fullFileName );
527 if( !lock->Valid() && lock->IsLockedByMe() )
533 if( !
Pgm().SingleInstance()->IsAnotherRunning() )
534 lock->OverrideLock();
539 msg.Printf(
_(
"PCB '%s' is already open by '%s' at '%s'." ),
540 wx_filename.GetFullName(),
542 lock->GetHostname() );
547 lock->OverrideLock();
562 wxFileName pro = fullFileName;
565 bool is_new = !wxFileName::IsFileReadable( fullFileName );
571 msg.Printf(
_(
"PCB '%s' does not exist. Do you wish to create it?" ), fullFileName );
573 if( !
IsOK(
this, msg ) )
581 :
_(
"Loading PCB" ), 1 );
609 wxString
path = wxPathOnly(
Prj().GetProjectFullName() );
642 BOARD* loadedBoard =
nullptr;
648 this, std::placeholders::_1 ) );
655 std::placeholders::_1 ) );
669 bool failedLoad =
false;
688 pi->SetQueryUserCallback(
689 [&]( wxString aTitle,
int aIcon, wxString aMessage, wxString aAction ) ->
bool
691 KIDIALOG dlg(
nullptr, aMessage, aTitle, wxOK | wxCANCEL | aIcon );
693 if( !aAction.IsEmpty() )
694 dlg.SetOKLabel( aAction );
701#if USE_INSTRUMENTATION
705 if(
config()->m_System.show_import_issues )
710 pi->SetProgressReporter( &progressReporter );
711 loadedBoard = pi->LoadBoard( fullFileName,
nullptr, &props, &
Prj() );
713#if USE_INSTRUMENTATION
715 printf(
"PCB_IO::Load(): %u usecs\n", stopTime - startTime );
720 msg.Printf(
_(
"Error loading PCB '%s'." ), fullFileName );
721 progressReporter.Hide();
728 if( ioe.
Problem() != wxT(
"CANCEL" ) )
730 msg.Printf(
_(
"Error loading PCB '%s'." ), fullFileName );
731 progressReporter.Hide();
737 catch(
const std::bad_alloc& )
739 msg.Printf(
_(
"Memory exhausted loading PCB '%s'" ), fullFileName );
740 progressReporter.Hide();
746 if( failedLoad || !loadedBoard )
762 errorReporter.ShowModal();
766 SetBoard( loadedBoard,
false, &progressReporter );
817 && loadedBoard->
GetGenerator().Lower() != wxT(
"gerbview" ) ) )
822 "It will be converted to the new format when saved." ),
832 wxFileName loadedBoardFn( fullFileName );
833 wxString libNickName = loadedBoardFn.GetName();
838 std::vector<FOOTPRINT*> loadedFootprints = pi->GetImportedCachedLibraryFootprints();
844 if( newLibPath.Length() > 0 )
848 for(
FOOTPRINT* footprint : loadedFootprints )
852 if( !footprint->GetFPID().GetLibItemName().empty() )
854 footprint->SetReference(
"REF**" );
855 piSexpr->FootprintSave( newLibPath, footprint );
861 wxLogError(
_(
"Error saving footprint %s to project specific library." )
863 footprint->GetFPID().GetUniStringLibItemName(),
870 wxString rel_path, env_path;
872 wxASSERT_MSG( wxGetEnv( project_env, &env_path ),
873 wxT(
"There is no project variable?" ) );
875 wxString result( newLibPath );
877 if( result.Replace( env_path, wxT(
"$(" ) + project_env + wxT(
")" ) ) )
881 wxT(
"KiCad" ), wxEmptyString );
892 wxLogError(
_(
"Error saving project specific footprint library table." )
900 LIB_ID libId = footprint->GetFPID();
906 footprint->SetFPID( libId );
915 fn.SetPath(
Prj().GetProjectPath() );
916 fn.SetName(
Prj().GetProjectName() );
919 wxString fname = fn.GetFullPath();
932 std::vector<ZONE*> toFill;
949#if 0 && defined(DEBUG)
973 bool aChangeProject )
976 wxFileName pcbFileName = aFileName;
986 wxString msg = wxString::Format(
_(
"Insufficient permissions to write file '%s'." ),
987 pcbFileName.GetFullPath() );
994 wxFileName projectFile( pcbFileName );
995 wxFileName rulesFile( pcbFileName );
1001 if( projectFile.FileExists() )
1005 else if( aChangeProject )
1013 if( currentRules.FileExists() && !rulesFile.FileExists() && aChangeProject )
1014 KiCopyFile( currentRules.GetFullPath(), rulesFile.GetFullPath(), msg );
1016 if( !msg.IsEmpty() )
1018 DisplayError(
this, wxString::Format(
_(
"Error saving custom rules file '%s'." ),
1019 rulesFile.GetFullPath() ) );
1022 if( projectFile.FileExists() )
1032 wxString tempFile = wxFileName::CreateTempFileName( wxS(
"pcbnew" ) );
1040 pi->SaveBoard( tempFile,
GetBoard(),
nullptr );
1044 DisplayError(
this, wxString::Format(
_(
"Error saving board file '%s'.\n%s" ),
1045 pcbFileName.GetFullPath(),
1048 lowerTxt.Printf(
_(
"Failed to create temporary file '%s'." ), tempFile );
1053 wxRemoveFile( tempFile );
1062 if( !wxRenameFile( tempFile, pcbFileName.GetFullPath() ) )
1064 DisplayError(
this, wxString::Format(
_(
"Error saving board file '%s'.\n"
1065 "Failed to rename temporary file '%s." ),
1066 pcbFileName.GetFullPath(),
1069 lowerTxt.Printf(
_(
"Failed to rename temporary file '%s'." ),
1077 if( !
Kiface().IsSingle() )
1088 LockFile( pcbFileName.GetFullPath() );
1095 wxFileName autoSaveFileName = pcbFileName;
1099 if( autoSaveFileName.FileExists() )
1100 wxRemoveFile( autoSaveFileName.GetFullPath() );
1102 lowerTxt.Printf(
_(
"File '%s' saved." ), pcbFileName.GetFullPath() );
1104 SetStatusText( lowerTxt, 0 );
1125 DisplayError(
this, wxString::Format(
_(
"Insufficient permissions to write file '%s'." ),
1126 pcbFileName.GetFullPath() ) );
1140 wxASSERT( pcbFileName.IsAbsolute() );
1142 pi->SaveBoard( pcbFileName.GetFullPath(),
GetBoard(),
nullptr );
1146 DisplayError(
this, wxString::Format(
_(
"Error saving board file '%s'.\n%s" ),
1147 pcbFileName.GetFullPath(),
1153 wxFileName projectFile( pcbFileName );
1154 wxFileName rulesFile( pcbFileName );
1160 if( aCreateProject && !projectFile.FileExists() )
1165 if( aCreateProject && currentRules.FileExists() && !rulesFile.FileExists() )
1166 KiCopyFile( currentRules.GetFullPath(), rulesFile.GetFullPath(), msg );
1168 if( !msg.IsEmpty() )
1170 DisplayError(
this, wxString::Format(
_(
"Error saving custom rules file '%s'." ),
1171 rulesFile.GetFullPath() ) );
1175 pcbFileName.GetFullPath() ) );
1183 wxFileName tmpFileName;
1189 wxString title = GetTitle();
1191 if(
GetBoard()->GetFileName().IsEmpty() )
1202 wxFileName autoSaveFileName = tmpFileName;
1207 if( !autoSaveFileName.IsOk() )
1212 if( !autoSaveFileName.IsDirWritable() )
1214 autoSaveFileName.SetPath( wxFileName::GetTempDir() );
1216 if( !autoSaveFileName.IsOk() || !autoSaveFileName.IsDirWritable() )
1221 wxT(
"Creating auto save file <" ) + autoSaveFileName.GetFullPath() + wxT(
">" ) );
1223 if(
SavePcbFile( autoSaveFileName.GetFullPath(),
false,
false ) )
1231 if( !
Kiface().IsSingle() &&
1277 if( dlg.ShowModal() != wxID_OK )
1285 if( pcbFileName.GetName().empty() )
1287 DisplayError(
this,
_(
"The board must be saved before generating IPC2581 file." ) );
1293 wxString msg = wxString::Format(
_(
"Insufficient permissions to write file '%s'." ),
1294 pcbFileName.GetFullPath() );
1300 wxString tempFile = wxFileName::CreateTempFileName( wxS(
"pcbnew_ipc" ) );
1309 props[
"OEMRef"] = dlg.
GetOEM();
1310 props[
"mpn"] = dlg.
GetMPN();
1311 props[
"mfg"] = dlg.
GetMfg();
1312 props[
"dist"] = dlg.
GetDist();
1321 pi->SetProgressReporter( &reporter );
1322 pi->SaveBoard( tempFile,
GetBoard(), &props );
1327 DisplayError(
this, wxString::Format(
_(
"Error generating IPC2581 file '%s'.\n%s" ),
1328 pcbFileName.GetFullPath(), ioe.
What() ) );
1330 lowerTxt.Printf(
_(
"Failed to create temporary file '%s'." ), tempFile );
1335 wxRemoveFile( tempFile );
1342 auto ret =
tp.submit( saveFile );
1345 std::future_status status = ret.wait_for( std::chrono::milliseconds( 250 ) );
1347 while( status != std::future_status::ready )
1350 status = ret.wait_for( std::chrono::milliseconds( 250 ) );
1358 catch(
const std::exception& e )
1360 wxLogError(
"Exception in IPC2581 generation: %s", e.what() );
1370 wxFileName tempfn = pcbFileName;
1372 wxFileName zipfn = tempFile;
1373 zipfn.SetExt(
"zip" );
1375 wxFFileOutputStream fnout( zipfn.GetFullPath() );
1376 wxZipOutputStream
zip( fnout );
1377 wxFFileInputStream fnin( tempFile );
1379 zip.PutNextEntry( tempfn.GetFullName() );
1384 wxRemoveFile( tempFile );
1385 tempFile = zipfn.GetFullPath();
1389 if( !wxRenameFile( tempFile, pcbFileName.GetFullPath() ) )
1391 DisplayError(
this, wxString::Format(
_(
"Error generating IPC2581 file '%s'.\n"
1392 "Failed to rename temporary file '%s." ),
1393 pcbFileName.GetFullPath(),
1396 lowerTxt.Printf(
_(
"Failed to rename temporary file '%s'." ),
KIFACE_BASE & Kiface()
Global KIFACE_BASE "get" accessor.
void SetContentModified(bool aModified=true)
bool test(size_t pos) const
int m_CopperEdgeClearance
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
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.
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
Adds an item to the container.
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
void SynchronizeProperties()
Copy the current project's text variables into the boards property cache.
bool m_LegacyCopperEdgeClearanceLoaded
int GetCount() const
Return the number of objects in the list.
wxString GetPrecision() const
wxString GetDistPN() const
wxString GetUnitsString() const
wxString GetOutputPath() const
Class DIALOG_HTML_REPORTER.
WX_HTML_REPORT_BOX * m_Reporter
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.
void NewDisplay(bool aForceImmediateRedraw=false)
Reload and refresh (rebuild) the 3D scene.
virtual APP_SETTINGS_BASE * config() const
Returns the settings object used in SaveSettings(), and is overloaded in KICAD_MANAGER_FRAME.
virtual void CheckForAutoSaveFile(const wxFileName &aFileName)
Check if an auto save file exists for aFileName and takes the appropriate action depending on the use...
void UpdateFileHistory(const wxString &FullFileName, FILE_HISTORY *aFileHistory=nullptr)
Update the list of recently opened files.
void ClearFileHistory(FILE_HISTORY *aFileHistory=nullptr)
Removes all files from the file history.
wxString GetMruPath() const
virtual void DeleteAutoSaveFile(const wxFileName &aFileName)
bool IsWritable(const wxFileName &aFileName, bool aVerbose=true)
Checks if aFileName can be written.
wxString GetFileFromHistory(int cmdId, const wxString &type, FILE_HISTORY *aFileHistory=nullptr)
Fetches 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
void SetMsgPanel(const std::vector< MSG_PANEL_ITEM > &aList)
Clear the message panel and populates it with the contents of aList.
bool LockFile(const wxString &aFileName)
Mark a schematic file as being in use.
bool GetCreateNewProject() const
Gets if this hook has attached controls to a dialog box.
bool IsAttachedToDialog() const
bool GetShowIssues() const
Hold a record identifying a library accessed by the appropriate footprint library #PLUGIN object in t...
static const std::vector< KICAD_T > AllBoardItems
A scan list for all editable board items.
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)
Checks the 'do not show again' setting for the dialog.
PROJECT & Prj() const
Return a reference to the PROJECT associated with this KIWAY.
Plugin class for import plugins that support remappable layers.
A logical library item identifier and consists of various portions much like a URI.
int SetLibNickname(const UTF8 &aLibNickname)
Override the logical library name portion of the LIB_ID to aLibNickname.
const UTF8 & GetLibItemName() const
bool InsertRow(LIB_TABLE_ROW *aRow, bool doReplace=false)
Adds aRow if it does not already exist or if doReplace is true.
void Save(const wxString &aFileName) const
Write this library table to aFileName in s-expression form.
static REPORTER & GetInstance()
static wxString GetDefaultUserProjectsPath()
Gets the default path we point users to create projects.
static TOOL_ACTION repairBoard
wxString GetDesignRulesPath()
Return the absolute path to the design rules file for the currently-loaded board.
wxString CreateNewProjectLibrary(const wxString &aLibName=wxEmptyString, const wxString &aProposedName=wxEmptyString)
const VECTOR2I GetPageSizeIU() const override
Works off of GetPageSettings() to return the size of the paper page in the internal units of this par...
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 * Get3DViewerFrame()
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 GenIPC2581File(wxCommandEvent &event)
Create and IPC2581 output file.
bool doAutoSave() override
Perform auto save when the board has been modified and not saved within the auto save interval.
void OnModify() override
Must be called after a board change to set the modified flag.
void OnClearFileHistory(wxCommandEvent &aEvent)
bool SavePcbCopy(const wxString &aFileName, bool aCreateProject=false)
Write the board data structures to aFileName.
bool OpenProjectFiles(const std::vector< wxString > &aFileSet, int aCtl=0) override
Load a KiCad board (.kicad_pcb) from aFileName.
void onBoardLoaded()
Update the state of the GUI after a new board is loaded or created.
void SaveProjectLocalSettings() override
Save changes to the project local settings.
bool Files_io_from_id(int aId)
Read and write board files according to aId.
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 Files_io(wxCommandEvent &event)
Call Files_io_from_id with the wxCommandEvent id.
void UpdateTitle()
Set the main window title bar text.
int inferLegacyEdgeClearance(BOARD *aBoard, bool aShowUserMsg=true)
const STRING_UTF8_MAP * m_importProperties
bool SavePcbFile(const wxString &aFileName, bool addToHistory=true, bool aChangeProject=true)
Write the board data structures to a aFileName.
void saveProjectSettings() override
Saves any design-related project settings associated with this frame.
bool importFile(const wxString &aFileName, int aFileType, const STRING_UTF8_MAP *aProperties=nullptr)
Load the given filename but sets the path to the current project path.
void OnFileHistory(wxCommandEvent &event)
static PLUGIN_REGISTRY * Instance()
static PCB_IO * PluginFind(PCB_FILE_T aFileType)
Return a #PLUGIN which the caller can use to import, export, save, or load design documents.
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.
@ LEGACY
Legacy Pcbnew file formats prior to s-expression.
static PCB_FILE_T FindPluginTypeFromBoardPath(const wxString &aFileName, int aCtl=0)
Return a plugin type given a path for a board file.
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)
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 (.
static FP_LIB_TABLE * PcbFootprintLibs(PROJECT *aProject)
Return the table of footprint libraries without Kiway.
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 FootprintLibTblName() const
Returns the path and filename of this project's footprint library table.
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.
void SaveProjectAs(const wxString &aFullPath, PROJECT *aProject=nullptr)
Sets the currently loaded project path and saves it (pointers remain valid) Note that this will not m...
void SaveProjectCopy(const wxString &aFullPath, PROJECT *aProject=nullptr)
Saves a copy of the current project under the given path.
bool SaveProject(const wxString &aFullPath=wxEmptyString, PROJECT *aProject=nullptr)
Saves a loaded project.
bool LoadProject(const wxString &aFullPath, bool aSetActive=true)
Loads a project or sets up a new project with a specified path.
bool UnloadProject(PROJECT *aProject, bool aSave=true)
Saves, unloads and unregisters the given PROJECT.
bool TriggerBackupIfNeeded(REPORTER &aReporter) const
Calls 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.
A name/value tuple with unique names and optional values.
An 8 bit string that is assuredly encoded in UTF8, and supplies special conversion support to and fro...
static void ResolvePossibleSymlinks(wxFileName &aFilename)
void Flush()
Build the HTML messages page.
bool HasMessage() const override
Returns true if the reporter client is non-empty.
void RemoveAllButtons()
Remove all the buttons that have been added by the user.
bool HasCloseButton() const
@ OUTDATED_SAVE
OUTDATED_SAVE Messages that should be cleared on save.
void Dismiss() override
Dismisses the infobar and updates the containing layout and AUI manager (if one is provided).
void AddCloseButton(const wxString &aTooltip=_("Hide this message."))
Add the default close button to the infobar on the right side.
MESSAGE_TYPE GetMessageType() const
void ShowMessage(const wxString &aMessage, int aFlags=wxICON_INFORMATION) override
Show the info bar with the provided message and icon.
Multi-thread safe progress reporter dialog, intended for use of tasks that parallel reporting back of...
A wrapper for reporting to a wxString object.
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 DisplayError(wxWindow *aParent, const wxString &aText, int aDisplayTime)
Display an error or warning message box with aMessage.
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.
This file is part of the common library.
Declaration of the eda_3d_viewer class.
void KiCopyFile(const wxString &aSrcPath, const wxString &aDestPath, wxString &aErrors)
#define WIN_STRING_DIR_SEP
#define UNIX_STRING_DIR_SEP
static const std::string ProjectFileExtension
static const std::string LegacyPcbFileExtension
static const std::string Ipc2581FileExtension
static const std::string AutoSaveFilePrefix
static const std::string DesignRulesFileExtension
static const std::string KiCadPcbFileExtension
static wxString PcbFileWildcard()
const wxChar *const traceAutoSave
Flag to enable auto save feature debug tracing.
std::unique_ptr< T > IO_RELEASER
Helper to hold and release an IO_BASE object when exceptions are thrown.
#define THROW_IO_ERROR(msg)
This file is part of the common library.
#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.
#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.
#define KI_FALLTHROUGH
The KI_FALLTHROUGH macro is to be used when switch statement cases should purposely fallthrough from ...
#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.
@ ID_IMPORT_NON_KICAD_BOARD
@ ID_MENU_RECOVER_BOARD_AUTOSAVE
SETTINGS_MANAGER * GetSettingsManager()
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 PROJECT_VAR_NAME
A variable name whose value holds the current project directory.
#define NAMELESS_PROJECT
default name for nameless projects
int StrPrintf(std::string *result, const char *format,...)
This is like sprintf() but the output is appended to a std::string instead of to a character array.
bool show_import_issues
Stored value for "show import issues" when importing non-KiCad designs to this application.
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.
BS::thread_pool thread_pool
thread_pool & GetKiCadThreadPool()
Get a reference to the current thread pool.
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.