44#include <wx/snglinst.h>
80#include <wx/stdpaths.h>
82#include <wx/filedlg.h>
83#include <wx/txtstrm.h>
84#include <wx/wfstream.h>
85#include <wx/zipstrm.h>
88#include "widgets/filedlg_hook_save_project.h"
91#define USE_INSTRUMENTATION 0
105 std::vector<IO_BASE::IO_FILE_DESC> descriptions;
118 wxCHECK( pi,
false );
125 descriptions.emplace_back( desc );
128 wxString fileFiltersStr;
129 std::vector<std::string> allExtensions;
130 std::set<wxString> allWildcardsSet;
134 if( !fileFiltersStr.IsEmpty() )
135 fileFiltersStr += wxChar(
'|' );
137 fileFiltersStr += desc.FileFilter();
139 for(
const std::string& ext : desc.m_FileExtensions )
141 allExtensions.emplace_back( ext );
146 wxString allWildcardsStr;
148 for(
const wxString& wildcard : allWildcardsSet )
149 allWildcardsStr << wildcard;
157 fileFiltersStr =
_(
"All supported formats" ) + wxT(
"|" ) + allWildcardsStr + wxT(
"|" )
161 wxFileName fileName( *aFileName );
165 if( fileName.FileExists() )
167 path = fileName.GetPath();
168 name = fileName.GetFullName();
181 wxFileDialog dlg( aParent,
182 kicadFormat ?
_(
"Open Board File" ) :
_(
"Import Non KiCad Board File" ),
183 path,
name, fileFiltersStr, wxFD_OPEN | wxFD_FILE_MUST_EXIST );
188 dlg.SetCustomizeHook( importOptions );
190 if( dlg.ShowModal() == wxID_OK )
192 *aFileName = dlg.GetPath();
193 aParent->
SetMruPath( wxFileName( dlg.GetPath() ).GetPath() );
219 wxFileName fn = *aFileName;
223 wxFileDialog dlg( aParent,
_(
"Save Board File As" ), fn.GetPath(), fn.GetFullName(), wildcard,
224 wxFD_SAVE | wxFD_OVERWRITE_PROMPT );
230 dlg.SetCustomizeHook( newProjectHook );
232 if( dlg.ShowModal() != wxID_OK )
235 *aFileName = dlg.GetPath();
241 *aCreateProject =
true;
253 if( !wxFileName::IsFileReadable( fn ) )
273 if( !
Kiface().IsSingle() )
302 wxFileName fn = currfn;
305 fn.SetName( rec_name );
307 if( !fn.FileExists() )
309 DisplayError(
m_frame, wxString::Format(
_(
"Recovery file '%s' not found." ), fn.GetFullPath() ) );
313 if( !
IsOK(
m_frame, wxString::Format(
_(
"OK to load recovery file '%s'?" ), fn.GetFullPath() ) ) )
333 if( !
IsOK(
m_frame, wxString::Format(
_(
"Revert '%s' to last version saved?" ), fn.GetFullPath() ) ) )
349 if( !
Kiface().IsSingle() )
355 wxString saveMsg =
_(
"Current board will be closed, save changes to '%s' before "
361 return m_frame->SaveBoard();
369 if( !
IsOK(
m_frame,
_(
"Current Board will be closed. Continue?" ) ) )
395 if( !
GetBoard()->GetFileName().IsEmpty() )
409 wxFileName::SplitPath(
GetBoard()->GetFileName(),
nullptr,
nullptr, &orig_name,
nullptr );
411 if( orig_name.IsEmpty() )
414 wxFileName savePath(
Prj().GetProjectFullName() );
416 if( !savePath.IsOk() || !savePath.IsDirWritable() )
420 if( !savePath.IsOk() || !savePath.IsDirWritable() )
425 wxString filename = fn.GetFullPath();
426 bool createProject =
false;
427 bool success =
false;
437 success =
SavePcbFile( filename, aSaveAs, createProject );
458 for(
int i = 0; i < collector.
GetCount(); i++ )
462 int itemWidth =
static_cast<PCB_SHAPE*
>( collector[i] )->GetWidth();
464 if( edgeWidth != -1 && edgeWidth != itemWidth )
467 edgeWidth = std::max( edgeWidth, itemWidth );
471 edgeWidth = itemWidth;
476 if( mixed && aShowUserMsg )
480 _(
"If the zones on this board are refilled the Copper Edge "
481 "Clearance setting will be used (see Board Setup > Design "
482 "Rules > Constraints).\n This may result in different fills "
483 "from previous KiCad versions which used the line thicknesses "
484 "of the board boundary on the Edge Cuts layer." ) );
487 return std::max( 0, edgeWidth / 2 );
494 if( aFileSet.size() != 1 )
496 UTF8 msg =
StrPrintf(
"Pcbnew:%s() takes a single filename", __func__ );
501 wxString fullFileName( aFileSet[0] );
502 wxFileName wx_filename( fullFileName );
509 wxASSERT_MSG( wx_filename.IsAbsolute(), wxT(
"Path is not absolute!" ) );
511 std::unique_ptr<LOCKFILE> lock = std::make_unique<LOCKFILE>( fullFileName );
513 if( !lock->Valid() && lock->IsLockedByMe() )
519 if( !
Pgm().SingleInstance()->IsAnotherRunning() )
520 lock->OverrideLock();
525 msg.Printf(
_(
"PCB '%s' is already open by '%s' at '%s'." ),
526 wx_filename.GetFullName(),
528 lock->GetHostname() );
533 lock->OverrideLock();
548 wxFileName pro = fullFileName;
551 bool is_new = !wxFileName::IsFileReadable( fullFileName );
557 msg.Printf(
_(
"PCB '%s' does not exist. Do you wish to create it?" ), fullFileName );
559 if( !
IsOK(
this, msg ) )
579 progressReporter.Hide();
630 BOARD* loadedBoard =
nullptr;
636 this, std::placeholders::_1 ) );
643 std::placeholders::_1 ) );
657 bool failedLoad =
false;
667 std::map<std::string, UTF8> props;
676 pi->SetQueryUserCallback(
677 [&]( wxString aTitle,
int aIcon, wxString aMessage, wxString aAction ) ->
bool
679 KIDIALOG dlg(
nullptr, aMessage, aTitle, wxOK | wxCANCEL | aIcon );
681 if( !aAction.IsEmpty() )
682 dlg.SetOKLabel( aAction );
689#if USE_INSTRUMENTATION
693 if(
config()->m_System.show_import_issues )
698 pi->SetProgressReporter( &progressReporter );
699 loadedBoard = pi->LoadBoard( fullFileName,
nullptr, &props, &
Prj() );
701#if USE_INSTRUMENTATION
703 printf(
"PCB_IO::Load(): %u usecs\n", stopTime - startTime );
708 msg.Printf(
_(
"Error loading PCB '%s'." ), fullFileName );
709 progressReporter.Hide();
716 if( ioe.
Problem() != wxT(
"CANCEL" ) )
718 msg.Printf(
_(
"Error loading PCB '%s'." ), fullFileName );
719 progressReporter.Hide();
725 catch(
const std::bad_alloc& )
727 msg.Printf(
_(
"Memory exhausted loading PCB '%s'" ), fullFileName );
728 progressReporter.Hide();
734 if( failedLoad || !loadedBoard )
754 SetBoard( loadedBoard,
false, &progressReporter );
813 && loadedBoard->
GetGenerator().Lower() != wxT(
"gerbview" ) ) )
818 "It will be converted to the new format when saved." ),
828 wxFileName loadedBoardFn( fullFileName );
829 wxString libNickName = loadedBoardFn.GetName();
834 std::vector<FOOTPRINT*> loadedFootprints = pi->GetImportedCachedLibraryFootprints();
841 if( newLibPath.Length() > 0 )
845 for(
FOOTPRINT* footprint : loadedFootprints )
849 if( !footprint->GetFPID().GetLibItemName().empty() )
851 footprint->SetReference(
"REF**" );
852 piSexpr->FootprintSave( newLibPath, footprint );
858 wxLogError(
_(
"Error saving footprint %s to project specific library." )
860 footprint->GetFPID().GetUniStringLibItemName(),
867 wxString rel_path, env_path;
869 wxASSERT_MSG( wxGetEnv( project_env, &env_path ),
870 wxT(
"There is no project variable?" ) );
872 wxString result( newLibPath );
874 if( result.Replace( env_path, wxT(
"$(" ) + project_env + wxT(
")" ) ) )
878 wxT(
"KiCad" ), wxEmptyString );
889 wxLogError(
_(
"Error saving project specific footprint library table." )
897 LIB_ID libId = footprint->GetFPID();
903 footprint->SetFPID( libId );
912 fn.SetPath(
Prj().GetProjectPath() );
913 fn.SetName(
Prj().GetProjectName() );
916 wxString fname = fn.GetFullPath();
929 std::vector<ZONE*> toFill;
955#if 0 && defined(DEBUG)
979 bool aChangeProject )
982 wxFileName pcbFileName = aFileName;
992 wxString msg = wxString::Format(
_(
"Insufficient permissions to write file '%s'." ),
993 pcbFileName.GetFullPath() );
1000 wxFileName projectFile( pcbFileName );
1001 wxFileName rulesFile( pcbFileName );
1007 if( projectFile.FileExists() )
1011 else if( aChangeProject )
1019 if( currentRules.FileExists() && !rulesFile.FileExists() && aChangeProject )
1020 KiCopyFile( currentRules.GetFullPath(), rulesFile.GetFullPath(), msg );
1022 if( !msg.IsEmpty() )
1024 DisplayError(
this, wxString::Format(
_(
"Error saving custom rules file '%s'." ),
1025 rulesFile.GetFullPath() ) );
1028 if( projectFile.FileExists() )
1045 pi->SaveBoard( pcbFileName.GetFullPath(),
GetBoard(),
nullptr );
1049 DisplayError(
this, wxString::Format(
_(
"Error saving board file '%s'.\n%s" ),
1050 pcbFileName.GetFullPath(),
1055 if( !
Kiface().IsSingle() )
1062 SetStatusText( upperTxt, 1 );
1069 LockFile( pcbFileName.GetFullPath() );
1076 wxFileName autoSaveFileName = pcbFileName;
1080 if( autoSaveFileName.FileExists() )
1081 wxRemoveFile( autoSaveFileName.GetFullPath() );
1083 lowerTxt.Printf(
_(
"File '%s' saved." ), pcbFileName.GetFullPath() );
1085 SetStatusText( lowerTxt, 0 );
1103 wxFileName pcbFileName( aFileName );
1109 DisplayError(
this, wxString::Format(
_(
"Insufficient permissions to write file '%s'." ),
1110 pcbFileName.GetFullPath() ) );
1125 wxASSERT( pcbFileName.IsAbsolute() );
1127 pi->SaveBoard( pcbFileName.GetFullPath(),
GetBoard(),
nullptr );
1133 DisplayError(
this, wxString::Format(
_(
"Error saving board file '%s'.\n%s" ),
1134 pcbFileName.GetFullPath(),
1141 wxFileName projectFile( pcbFileName );
1142 wxFileName rulesFile( pcbFileName );
1148 if( aCreateProject && !projectFile.FileExists() )
1153 if( aCreateProject && currentRules.FileExists() && !rulesFile.FileExists() )
1154 KiCopyFile( currentRules.GetFullPath(), rulesFile.GetFullPath(), msg );
1156 if( !msg.IsEmpty() && !aHeadless )
1158 DisplayError(
this, wxString::Format(
_(
"Error saving custom rules file '%s'." ),
1159 rulesFile.GetFullPath() ) );
1168 wxFileName tmpFileName;
1174 wxString title = GetTitle();
1176 if(
GetBoard()->GetFileName().IsEmpty() )
1187 wxFileName autoSaveFileName = tmpFileName;
1192 if( !autoSaveFileName.IsOk() )
1197 if( !autoSaveFileName.IsDirWritable() )
1199 autoSaveFileName.SetPath( wxFileName::GetTempDir() );
1201 if( !autoSaveFileName.IsOk() || !autoSaveFileName.IsDirWritable() )
1206 wxT(
"Creating auto save file <" ) + autoSaveFileName.GetFullPath() + wxT(
">" ) );
1208 if(
SavePcbFile( autoSaveFileName.GetFullPath(),
false,
false ) )
1216 if( !
Kiface().IsSingle() &&
1236 const std::map<std::string, UTF8>* aProperties )
1274 if( pcbFileName.GetName().empty() )
1283 pcbFileName.GetFullPath() ) );
1287 wxString tempFile = wxFileName::CreateTempFileName( wxS(
"pcbnew_ipc" ) );
1291 std::map<std::string, UTF8> props;
1296 props[
"OEMRef"] = dlg.
GetOEM();
1297 props[
"mpn"] = dlg.
GetMPN();
1298 props[
"mfg"] = dlg.
GetMfg();
1299 props[
"dist"] = dlg.
GetDist();
1308 pi->SetProgressReporter( &reporter );
1315 pcbFileName.GetFullPath(),
1318 lowerTxt.Printf(
_(
"Failed to create temporary file '%s'." ), tempFile );
1323 wxRemoveFile( tempFile );
1330 auto ret =
tp.submit( saveFile );
1333 std::future_status status = ret.wait_for( std::chrono::milliseconds( 250 ) );
1335 while( status != std::future_status::ready )
1338 status = ret.wait_for( std::chrono::milliseconds( 250 ) );
1346 catch(
const std::exception& e )
1348 wxLogError(
"Exception in IPC-2581 generation: %s", e.what() );
1358 wxFileName tempfn = pcbFileName;
1360 wxFileName zipfn = tempFile;
1361 zipfn.SetExt(
"zip" );
1364 wxFFileOutputStream fnout( zipfn.GetFullPath() );
1365 wxZipOutputStream
zip( fnout );
1366 wxFFileInputStream fnin( tempFile );
1368 zip.PutNextEntry( tempfn.GetFullName() );
1372 wxRemoveFile( tempFile );
1373 tempFile = zipfn.GetFullPath();
1377 if( !wxRenameFile( tempFile, pcbFileName.GetFullPath() ) )
1380 "Failed to rename temporary file '%s." ),
1381 pcbFileName.GetFullPath(),
1384 lowerTxt.Printf(
_(
"Failed to rename temporary file '%s'." ),
KIFACE_BASE & Kiface()
Global KIFACE_BASE "get" accessor.
void SetContentModified(bool aModified=true)
int m_CopperEdgeClearance
int RescueAutosave(const TOOL_EVENT &aEvent)
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)
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.
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.
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
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.
wxString GetPrecision() const
wxString GetDistPN() const
wxString GetUnitsString() const
wxString GetOutputPath() const
static void GenerateODBPPFiles(const JOB_EXPORT_PCB_ODB &aJob, BOARD *aBoard, PCB_EDIT_FRAME *aParentFrame=nullptr, PROGRESS_REPORTER *aProgressReporter=nullptr, REPORTER *aErrorReporter=nullptr)
wxString GetOutputPath() const
int GetCompressFormat() const
wxString GetUnitsString() 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
Return 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...
SETTINGS_MANAGER * GetSettingsManager() const
void UpdateFileHistory(const wxString &FullFileName, FILE_HISTORY *aFileHistory=nullptr)
Update the list of recently opened files.
void ClearFileHistory(FILE_HISTORY *aFileHistory=nullptr)
Remove all files from the file history.
wxString GetMruPath() const
virtual void DeleteAutoSaveFile(const wxFileName &aFileName)
bool IsWritable(const wxFileName &aFileName, bool aVerbose=true)
Check if aFileName can be written.
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
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?
ODB_COMPRESSION m_compressionMode
void SetConfiguredOutputPath(const wxString &aPath)
Sets the configured output path for the job, this path is always saved to file.
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.
PROJECT & Prj() const
Return a reference to the PROJECT associated with this KIWAY.
Plugin class for import plugins that support remappable layers.
void SynchronizeTimeDomainProperties() const
Ensure time domain properties provider is synced with board / project settings if required.
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
static TOOL_ACTION rehatchShapes
wxString GetDesignRulesPath()
Return the absolute path to the design rules file for the currently-loaded board.
wxString CreateNewProjectLibrary(const wxString &aDialogTitle, const wxString &aLibName)
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()
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 DoAutoSave()
Perform auto save when the board has been modified and not saved within the auto save interval.
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 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
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()
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)
Set the currently loaded project path and saves it (pointers remain valid).
void SaveProjectCopy(const wxString &aFullPath, PROJECT *aProject=nullptr)
Save a copy of the current project under the given path.
bool SaveProject(const wxString &aFullPath=wxEmptyString, PROJECT *aProject=nullptr)
Save a loaded project.
bool LoadProject(const wxString &aFullPath, bool aSetActive=true)
Load a project or sets up a new project with a specified 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.
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.
@ GENERIC
GENERIC Are messages that do not have special handling.
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.
bool HasMessage() const override
Returns true if the reporter client is non-empty.
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.
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 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.
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.
thread_pool & GetKiCadThreadPool()
Get a reference to the current thread pool.
BS::thread_pool 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.