31#undef HAVE_CLOCK_GETTIME
130 wxFileName pro = aFileName;
133 wxString projectPath = pro.GetFullPath();
143 if( wxFileExists( projectPath ) )
173 bds.
m_DRCEngine = std::make_shared<DRC_ENGINE>( brd, &bds );
177 wxFileName rules = pro;
200 wxFileName boardFn = aFileName;
201 wxFileName proFn = aFileName;
203 proFn.MakeAbsolute();
205 wxString projectPath = proFn.GetFullPath();
218 bds.
m_DRCEngine = std::make_shared<DRC_ENGINE>( brd, &bds );
260 wxFileName pro = aFileName;
289 return project->PcbFootprintLibs();
295 wxArrayString footprintLibraryNames;
300 return footprintLibraryNames;
303 footprintLibraryNames.Add(
name );
305 return footprintLibraryNames;
311 wxArrayString footprintNames;
316 return footprintNames;
320 return footprintNames;
353bool ExportVRML(
const wxString& aFullFileName,
double aMMtoWRMLunit,
bool aExport3DFiles,
354 bool aUseRelativePaths,
const wxString& a3D_Subdir,
double aXRef,
double aYRef )
359 aExport3DFiles, aUseRelativePaths,
360 a3D_Subdir, aXRef, aYRef );
423 std::deque<BOARD_ITEM*> items;
429 std::for_each( selection.
begin(), selection.
end(),
432 items.push_back( static_cast<BOARD_ITEM*>( item ) );
447 bool aReportAllTrackErrors )
449 wxCHECK( aBoard,
false );
452 std::shared_ptr<DRC_ENGINE> engine = bds.
m_DRCEngine;
457 bds.
m_DRCEngine = std::make_shared<DRC_ENGINE>( aBoard, &bds );
461 wxCHECK( engine,
false );
472 wxCHECK( prj,
false );
474 wxString drcRulesPath = prj->
AbsolutePath( fn.GetFullName() );
490 engine->InitEngine( drcRulesPath );
494 fprintf( stderr,
"Init DRC engine: err <%s>\n",
TO_UTF8( err.
What() ) ); fflush( stderr);
498 std::vector<std::shared_ptr<DRC_ITEM>> footprints;
499 std::vector<std::shared_ptr<DRC_ITEM>> unconnected;
500 std::vector<std::shared_ptr<DRC_ITEM>> violations;
502 engine->SetProgressReporter(
nullptr );
504 engine->SetViolationHandler(
505 [&](
const std::shared_ptr<DRC_ITEM>& aItem,
VECTOR2D aPos,
int aLayer )
512 footprints.push_back( aItem );
516 unconnected.push_back( aItem );
520 violations.push_back( aItem );
524 engine->RunTests( aUnits, aReportAllTrackErrors,
false );
525 engine->ClearViolationHandler();
529 FILE* fp = wxFopen( aFileName, wxT(
"w" ) );
534 std::map<KIID, EDA_ITEM*> itemMap;
539 wxDateTime now = wxDateTime::Now();
541 fprintf( fp,
"** Created on %s **\n",
TO_UTF8( now.Format( wxT(
"%F %T" ) ) ) );
543 fprintf( fp,
"\n** Found %d DRC violations **\n",
static_cast<int>( violations.size() ) );
545 for(
const std::shared_ptr<DRC_ITEM>& item : violations )
547 SEVERITY severity = item->GetParent() ? item->GetParent()->GetSeverity()
549 fprintf( fp,
"%s",
TO_UTF8( item->ShowReport( &unitsProvider, severity, itemMap ) ) );
552 fprintf( fp,
"\n** Found %d unconnected pads **\n",
static_cast<int>( unconnected.size() ) );
554 for(
const std::shared_ptr<DRC_ITEM>& item : unconnected )
557 fprintf( fp,
"%s",
TO_UTF8( item->ShowReport( &unitsProvider, severity, itemMap ) ) );
560 fprintf( fp,
"\n** Found %d Footprint errors **\n",
static_cast<int>( footprints.size() ) );
562 for(
const std::shared_ptr<DRC_ITEM>& item : footprints )
565 fprintf( fp,
"%s",
TO_UTF8( item->ShowReport( &unitsProvider, severity, itemMap ) ) );
568 fprintf( fp,
"\n** End of Report **\n" );
Class PCBNEW_ACTION_PLUGINS.
constexpr EDA_IU_SCALE pcbIUScale
static bool IsActionRunning()
Container for design settings for a BOARD object.
std::shared_ptr< DRC_ENGINE > m_DRCEngine
SEVERITY GetSeverity(int aDRCErrorCode)
Information pertinent to a Pcbnew printed circuit board.
void Add(BOARD_ITEM *aItem, ADD_MODE aMode=ADD_MODE::INSERT, bool aSkipConnectivity=false) override
Removes an item from the container.
GAL_SET m_LegacyVisibleItems
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
void FillItemMap(std::map< KIID, EDA_ITEM * > &aMap)
const wxString GetLayerName(PCB_LAYER_ID aLayer) const
Return the name of a aLayer.
PROJECT * GetProject() const
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
std::vector< PCB_MARKER * > ResolveDRCExclusions()
Rebuild DRC markers from the serialized data in BOARD_DESIGN_SETTINGS.
SETTINGS_MANAGER * GetSettingsManager() const
A base class for most all the KiCad significant classes used in schematics and boards.
ENUM_MAP & Map(T aValue, const wxString &aName)
static ENUM_MAP< T > & Instance()
ENUM_MAP & Undefined(T aValue)
void FootprintEnumerate(wxArrayString &aFootprintNames, const wxString &aNickname, bool aBestEfforts)
Return a list of footprint names contained within the library given by aNickname.
virtual const wxString What() const
A composite of Problem() and Where()
PCB_FILE_T
The set of file types that the IO_MGR knows about, and for which there has been a plugin written.
@ LEGACY
Legacy Pcbnew file formats prior to s-expression.
@ KICAD_SEXP
S-expression Pcbnew file format.
static BOARD * Load(PCB_FILE_T aFileType, const wxString &aFileName, BOARD *aAppendToMe=nullptr, const STRING_UTF8_MAP *aProperties=nullptr, PROJECT *aProject=nullptr, PROGRESS_REPORTER *aProgressReporter=nullptr)
Find the requested PLUGIN and if found, calls the PLUGIN::Load() function on it using the arguments p...
static void Save(PCB_FILE_T aFileType, const wxString &aFileName, BOARD *aBoard, const STRING_UTF8_MAP *aProperties=nullptr)
Write either a full aBoard to a storage file in a format that this implementation knows about,...
std::vector< wxString > GetLogicalLibs()
Return the logical library names, all of them that are pertinent to a look up done on this LIB_TABLE.
Instantiate the current locale within a scope in which you are expecting exceptions to be thrown.
LSEQ is a sequence (and therefore also a set) of PCB_LAYER_IDs.
static LSET AllLayersMask()
static const wxChar * Name(PCB_LAYER_ID aLayerId)
Return the fixed name association with aLayerId.
The main frame for Pcbnew.
void UpdateUserInterface()
Update the layer manager and other widgets from the board setup (layer and items visibility,...
void ExportFootprintsToLibrary(bool aStoreInNewLib, const wxString &aLibName=wxEmptyString, wxString *aLibPath=nullptr)
Save footprints in a library:
bool ImportSpecctraSession(const wxString &aFullFilename)
Import a specctra *.ses file and use it to relocate MODULEs and to replace all vias and tracks in an ...
bool ExportVRML_File(const wxString &aFullFileName, double aMMtoWRMLunit, bool aExport3DFiles, bool aUseRelativePaths, const wxString &a3D_Subdir, double aXRef, double aYRef)
Create the file(s) exporting current BOARD to a VRML file.
void RebuildAndRefresh()
Rebuilds board connectivity, refreshes canvas.
SELECTION & GetCurrentSelection() override
Get the current selection from the canvas area.
bool ExportSpecctraFile(const wxString &aFullFilename)
Export the current BOARD to a specctra dsn file.
Container for project specific data.
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.
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...
bool LoadProject(const wxString &aFullPath, bool aSetActive=true)
Loads a project or sets up a new project with a specified path.
PROJECT * GetProject(const wxString &aFullPath) const
Retrieves a loaded project by name.
PROJECT & Prj() const
A helper while we are not MDI-capable – return the one and only project.
EDA_UNITS GetUserUnits() const
@ DRCE_DUPLICATE_FOOTPRINT
const std::string LegacyPcbFileExtension
const std::string KiCadPcbFileExtension
const std::string ProjectFileExtension
const std::string DesignRulesFileExtension
void ignore_unused(const T &)
@ 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 TO_UTF8(wxstring)
Convert a wxString to a UTF8 encoded C string for all wxWidgets build modes.
bool ImportSpecctraSES(wxString &aFullFilename)
Import a specctra *.ses file and use it to relocate MODULEs and to replace all vias and tracks in an ...
SETTINGS_MANAGER * GetSettingsManager()
bool WriteDRCReport(BOARD *aBoard, const wxString &aFileName, EDA_UNITS aUnits, bool aReportAllTrackErrors)
Run the DRC check on the given board and writes the results to a report file.
BOARD * CreateEmptyBoard()
Construct a default BOARD with a temporary (no filename) project.
wxArrayString GetFootprintLibraries()
Get the nicknames of all of the footprint libraries configured in pcbnew in both the project and glob...
FP_LIB_TABLE * GetFootprintLibraryTable()
int GetUserUnits()
Return the currently selected user unit value for the interface.
wxArrayString GetFootprints(const wxString &aNickName)
Get the names of all of the footprints available in a footprint library.
void ScriptingSetPcbEditFrame(PCB_EDIT_FRAME *aPcbEditFrame)
static PCB_EDIT_FRAME * s_PcbEditFrame
bool IsActionRunning()
Are we currently in an action plugin?
void UpdateUserInterface()
Update the layer manager and other widgets from the board setup (layer and items visibility,...
bool SaveBoard(wxString &aFileName, BOARD *aBoard, IO_MGR::PCB_FILE_T aFormat, bool aSkipSettings)
bool ExportSpecctraDSN(wxString &aFullFilename)
Will export the current BOARD to a specctra dsn file.
void Refresh()
Update the board display after modifying it by a python script (note: it is automatically called by a...
std::deque< BOARD_ITEM * > GetCurrentSelection()
Get the list of selected objects.
bool ExportVRML(const wxString &aFullFileName, double aMMtoWRMLunit, bool aExport3DFiles, bool aUseRelativePaths, const wxString &a3D_Subdir, double aXRef, double aYRef)
Export the current BOARD to a VRML (wrl) file.
static SETTINGS_MANAGER * s_SettingsManager
bool ExportFootprintsToLibrary(bool aStoreInNewLib, const wxString &aLibName, wxString *aLibPath)
Save footprints in a library:
PROJECT * GetDefaultProject()
BOARD * NewBoard(wxString &aFileName)
Creates a new board and project with the given filename (will overwrite existing files!...
BOARD * LoadBoard(wxString &aFileName)
void ExportBoardToSpecctraFile(BOARD *aBoard, const wxString &aFullFilename)
Helper method to export board to DSN file.
std::vector< FAB_LAYER_COLOR > dummy
A filename or source description, a problem input line, a line number, a byte offset,...
Definition of file extensions used in Kicad.