31#undef HAVE_CLOCK_GETTIME
146 return LoadBoard( aFileName, aFormat,
false );
152 wxFileName pro = aFileName;
155 wxString projectPath = pro.GetFullPath();
160 wxInitAllImageHandlers();
166 if( wxFileExists( projectPath ) )
185 BOARD* brd =
nullptr;
208 { brd->GetEmbeddedFiles() } );
214 wxFprintf( stderr,
_(
"Error loading drawing sheet '%s': %s" ),
243 bds.
m_DRCEngine = std::make_shared<DRC_ENGINE>( brd, &bds );
247 wxFileName rules = pro;
271 wxFileName boardFn = aFileName;
272 wxFileName proFn = aFileName;
274 proFn.MakeAbsolute();
276 wxString projectPath = proFn.GetFullPath();
285 bds.
m_DRCEngine = std::make_shared<DRC_ENGINE>( brd, &bds );
323 wxFileName pro = aFileName;
358 wxArrayString footprintLibraryNames;
363 return footprintLibraryNames;
366 footprintLibraryNames.Add(
name );
368 return footprintLibraryNames;
374 wxArrayString footprintNames;
379 return footprintNames;
382 footprintNames.assign( names.begin(), names.end() );
384 return footprintNames;
417bool ExportVRML(
const wxString& aFullFileName,
double aMMtoWRMLunit,
bool aIncludeUnspecified,
418 bool aIncludeDNP,
bool aExport3DFiles,
419 bool aUseRelativePaths,
const wxString& a3D_Subdir,
double aXRef,
double aYRef )
423 bool ok =
s_PcbEditFrame->ExportVRML_File( aFullFileName, aMMtoWRMLunit,
424 aIncludeUnspecified, aIncludeDNP,
425 aExport3DFiles, aUseRelativePaths,
426 a3D_Subdir, aXRef, aYRef );
467 s_PcbEditFrame->ExportFootprintsToLibrary( aStoreInNewLib, aLibName, aLibPath );
503 std::deque<BOARD_ITEM*> items;
509 std::for_each( selection.
begin(), selection.
end(),
512 if( item->IsBOARD_ITEM() )
513 items.push_back( static_cast<BOARD_ITEM*>( item ) );
536 bool aReportAllTrackErrors )
538 wxCHECK( aBoard,
false );
541 std::shared_ptr<DRC_ENGINE> engine = bds.
m_DRCEngine;
546 bds.
m_DRCEngine = std::make_shared<DRC_ENGINE>( aBoard, &bds );
550 wxCHECK( engine,
false );
561 wxCHECK( prj,
false );
563 wxString drcRulesPath = prj->
AbsolutePath( fn.GetFullName() );
579 engine->InitEngine( drcRulesPath );
583 fprintf( stderr,
"Init DRC engine: err <%s>\n",
TO_UTF8( err.
What() ) ); fflush( stderr);
587 std::vector<std::shared_ptr<DRC_ITEM>> footprints;
588 std::vector<std::shared_ptr<DRC_ITEM>> unconnected;
589 std::vector<std::shared_ptr<DRC_ITEM>> violations;
591 engine->SetProgressReporter(
nullptr );
593 engine->SetViolationHandler(
594 [&](
const std::shared_ptr<DRC_ITEM>& aItem,
const VECTOR2D& aPos,
int aLayer,
595 const std::function<
void(
PCB_MARKER* )>& aPathGenerator )
605 footprints.push_back( aItem );
609 unconnected.push_back( aItem );
613 violations.push_back( aItem );
619 engine->RunTests( aUnits, aReportAllTrackErrors,
false );
620 engine->ClearViolationHandler();
627 FILE* fp = wxFopen( aFileName, wxT(
"w" ) );
632 std::map<KIID, EDA_ITEM*> itemMap;
637 wxDateTime now = wxDateTime::Now();
639 fprintf( fp,
"** Created on %s **\n",
TO_UTF8( now.Format( wxT(
"%F %T" ) ) ) );
641 fprintf( fp,
"\n** Found %d DRC violations **\n",
static_cast<int>( violations.size() ) );
643 for(
const std::shared_ptr<DRC_ITEM>& item : violations )
645 SEVERITY severity = item->GetParent() ? item->GetParent()->GetSeverity()
647 fprintf( fp,
"%s",
TO_UTF8( item->ShowReport( &unitsProvider, severity, itemMap ) ) );
650 fprintf( fp,
"\n** Found %d unconnected pads **\n",
static_cast<int>( unconnected.size() ) );
652 for(
const std::shared_ptr<DRC_ITEM>& item : unconnected )
655 fprintf( fp,
"%s",
TO_UTF8( item->ShowReport( &unitsProvider, severity, itemMap ) ) );
658 fprintf( fp,
"\n** Found %d Footprint errors **\n",
static_cast<int>( footprints.size() ) );
660 for(
const std::shared_ptr<DRC_ITEM>& item : footprints )
663 fprintf( fp,
"%s",
TO_UTF8( item->ShowReport( &unitsProvider, severity, itemMap ) ) );
666 fprintf( fp,
"\n** End of Report **\n" );
Class PCBNEW_ACTION_PLUGINS.
constexpr EDA_IU_SCALE pcbIUScale
static bool IsActionRunning()
static wxString m_DrawingSheetFileName
the name of the drawing sheet file, or empty to use the default drawing sheet
Container for design settings for a BOARD object.
std::shared_ptr< DRC_ENGINE > m_DRCEngine
SEVERITY GetSeverity(int aDRCErrorCode)
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
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
void UpdateUserUnits(BOARD_ITEM *aItem, KIGFX::VIEW *aView)
Update any references within aItem (or its descendants) to the user units.
bool BuildConnectivity(PROGRESS_REPORTER *aReporter=nullptr)
Build or rebuild the board connectivity database for the board, especially the list of connected item...
void RecordDRCExclusions()
Scan existing markers and record data from any that are Excluded.
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
std::vector< PCB_MARKER * > ResolveDRCExclusions(bool aCreateMarkers)
Rebuild DRC markers from the serialized data in BOARD_DESIGN_SETTINGS.
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
void DeleteMARKERs()
Delete all MARKERS from the board.
void InitEngine(const wxFileName &aRulePath)
Initialize the DRC engine.
static DS_DATA_MODEL & GetTheInstance()
Return the instance of DS_DATA_MODEL used in the application.
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)
Provide an extensible class to resolve 3D model paths.
virtual const wxString What() const
A composite of Problem() and Where()
std::vector< wxString > GetLibraryNames() const
Returns a list of library nicknames that are available (skips any that failed to load)
static const LSET & AllLayersMask()
static wxString Name(PCB_LAYER_ID aLayerId)
Return the fixed name association with aLayerId.
The main frame for Pcbnew.
static BOARD * Load(PCB_FILE_T aFileType, const wxString &aFileName, BOARD *aAppendToMe=nullptr, const std::map< std::string, UTF8 > *aProperties=nullptr, PROJECT *aProject=nullptr, PROGRESS_REPORTER *aProgressReporter=nullptr)
Find the requested #PLUGIN and if found, calls the #PLUGIN::LoadBoard() function on it using the argu...
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 void Save(PCB_FILE_T aFileType, const wxString &aFileName, BOARD *aBoard, const std::map< std::string, UTF8 > *aProperties=nullptr)
Write either a full aBoard to a storage file in a format that this implementation knows about,...
static FOOTPRINT_LIBRARY_ADAPTER * FootprintLibAdapter(PROJECT *aProject)
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)
Set the currently loaded project path and saves it (pointers remain valid).
COMMON_SETTINGS * GetCommonSettings() const
Retrieve the common settings shared by all applications.
bool LoadProject(const wxString &aFullPath, bool aSetActive=true)
Load a project or sets up a new project with a specified path.
PROJECT * GetProject(const wxString &aFullPath) const
Retrieve a loaded project by name.
@ DRCE_SCHEMATIC_FIELDS_PARITY
@ DRCE_DUPLICATE_FOOTPRINT
static FILENAME_RESOLVER * resolver
static const std::string ProjectFileExtension
static const std::string LegacyPcbFileExtension
static const std::string DesignRulesFileExtension
static const std::string KiCadPcbFileExtension
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.
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.
void ExportBoardToSpecctraFile(BOARD *aBoard, const wxString &aFullFilename)
Helper method to export board to DSN file.
bool ImportSpecctraSession(BOARD *aBoard, const wxString &fullFileName)
Helper method to import SES file to a board.
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()
void ScriptingOnDestructPcbEditFrame(PCB_EDIT_FRAME *aPcbEditFrame)
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.
bool ExportVRML(const wxString &aFullFileName, double aMMtoWRMLunit, bool aIncludeUnspecified, bool aIncludeDNP, bool aExport3DFiles, bool aUseRelativePaths, const wxString &a3D_Subdir, double aXRef, double aYRef)
Export the current BOARD to a VRML (wrl) file.
wxArrayString GetFootprintLibraries()
Get the nicknames of all of the footprint libraries configured in pcbnew in both the project and glob...
FOOTPRINT_LIBRARY_ADAPTER * getFootprintAdapter()
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?
bool SaveBoard(wxString &aFileName, BOARD *aBoard, PCB_IO_MGR::PCB_FILE_T aFormat, bool aSkipSettings)
void UpdateUserInterface()
Update the layer manager and other widgets from the board setup (layer and items visibility,...
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.
wxString GetLanguage()
Get the language string from COMMON_SETTINGS.
void FocusOnItem(BOARD_ITEM *aItem, PCB_LAYER_ID aLayer)
Focus the view on the target item.
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(const wxString &aFileName, bool aSetActive)
Loads a board from file This function identifies the file type by extension and determines the correc...
PGM_BASE * PgmOrNull()
Return a reference that can be nullptr when running a shared lib from a script, not from a kicad app.
#define TO_UTF8(wxstring)
Convert a wxString to a UTF8 encoded C string for all wxWidgets build modes.
A filename or source description, a problem input line, a line number, a byte offset,...
VECTOR2< double > VECTOR2D
Definition of file extensions used in Kicad.