KiCad PCB EDA Suite
Loading...
Searching...
No Matches
pcbnew_scripting_helpers.cpp
Go to the documentation of this file.
1/*
2 * This program source code file is part of KiCad, a free EDA CAD application.
3 *
4 * Copyright (C) 2012 NBEE Embedded Systems, Miguel Angel Ajo <[email protected]>
5 * Copyright The KiCad Developers, see AUTHORS.txt for contributors.
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version 2
10 * of the License, or (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, you may find one here:
19 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
20 * or you may search the http://www.gnu.org website for the version 2 license,
21 * or you may write to the Free Software Foundation, Inc.,
22 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
23 */
24
29
30#include <Python.h>
31#undef HAVE_CLOCK_GETTIME // macro is defined in Python.h and causes redefine warning
32
34
35#include <action_plugin.h>
36#include <board.h>
39#include <pcb_marker.h>
40#include <cstdlib>
42#include <drc/drc_engine.h>
43#include <drc/drc_item.h>
45#include <core/ignore.h>
46#include <pcb_io/pcb_io_mgr.h>
47#include <string_utils.h>
48#include <filename_resolver.h>
49#include <macros.h>
51#include <pgm_base.h>
53#include <project.h>
54#include <project_pcb.h>
58#include <specctra.h>
61#include <wx/app.h>
62#include <wx/crt.h>
63#include <wx/image.h>
64#include <properties/property.h>
66
69
70
72{
73 if( s_PcbEditFrame )
74 return s_PcbEditFrame->GetBoard();
75 else
76 return nullptr;
77}
78
79
81{
82 s_PcbEditFrame = aPcbEditFrame;
83}
84
85
87{
88 if( s_PcbEditFrame == aPcbEditFrame )
89 s_PcbEditFrame = nullptr;
90}
91
92
93BOARD* LoadBoard( const wxString& aFileName, bool aSetActive )
94{
95 if( aFileName.EndsWith( FILEEXT::KiCadPcbFileExtension ) )
96 return LoadBoard( aFileName, PCB_IO_MGR::KICAD_SEXP, aSetActive );
97 else if( aFileName.EndsWith( FILEEXT::LegacyPcbFileExtension ) )
98 return LoadBoard( aFileName, PCB_IO_MGR::LEGACY, aSetActive );
99
100 // as fall back for any other kind use the legacy format
101 return LoadBoard( aFileName, PCB_IO_MGR::LEGACY, aSetActive );
102}
103
104
105BOARD* LoadBoard( const wxString& aFileName )
106{
107 return LoadBoard( aFileName, false );
108}
109
110
112{
113 if( !s_SettingsManager )
114 {
115 if( s_PcbEditFrame )
116 {
117 s_SettingsManager = s_PcbEditFrame->GetSettingsManager();
118 }
119 else
120 {
121 // Ensure wx system settings stuff is available
122 ignore_unused( wxTheApp );
124 }
125 }
126
127 return s_SettingsManager;
128}
129
130
132{
134
135 if( !project )
136 {
139 }
140
141 return project;
142}
143
144BOARD* LoadBoard( const wxString& aFileName, PCB_IO_MGR::PCB_FILE_T aFormat )
145{
146 return LoadBoard( aFileName, aFormat, false );
147}
148
149
150BOARD* LoadBoard( const wxString& aFileName, PCB_IO_MGR::PCB_FILE_T aFormat, bool aSetActive )
151{
152 wxFileName pro = aFileName;
153 pro.SetExt( FILEEXT::ProjectFileExtension );
154 pro.MakeAbsolute();
155 wxString projectPath = pro.GetFullPath();
156
157 // Ensure image handlers are loaded, because a board can include bitmap images
158 // using various formats.
159 // By default only the BMP handler is available.
160 wxInitAllImageHandlers();
161
163
164 PROJECT* project = settingsManager.GetProject( projectPath );
165
166 if( !project )
167 {
168 if( wxFileExists( projectPath ) )
169 {
170 // cli
171 settingsManager.LoadProject( projectPath, aSetActive );
172 project = settingsManager.GetProject( projectPath );
173 }
174 }
175 else if( s_PcbEditFrame && project == &settingsManager.Prj() )
176 {
177 // Project is already loaded? Then so is the board
178 return s_PcbEditFrame->GetBoard();
179 }
180
181 // Board cannot be loaded without a project, so create the default project
182 if( !project )
184
185 BASE_SCREEN::m_DrawingSheetFileName = project->GetProjectFile().m_BoardDrawingSheetFile;
186
187 BOARD* brd = nullptr;
188 try
189 {
190 brd = PCB_IO_MGR::Load( aFormat, aFileName );
191 }
192 catch( ... )
193 {
194 brd = nullptr;
195 }
196
197 if( brd )
198 {
199 // Load the drawing sheet from the filename stored in BASE_SCREEN::m_DrawingSheetFileName.
200 // If empty, or not existing, the default drawing sheet is loaded.
202 resolver.SetProject( project );
203
204 // a PGM_BASE* process can be nullptr when running from a python script
205 // So use PgmOrNull() instead of &Pgm() to initialize the resolver
206 resolver.SetProgramBase( PgmOrNull() );
207
208 wxString filename = resolver.ResolvePath( BASE_SCREEN::m_DrawingSheetFileName,
209 project->GetProjectPath(),
210 { brd->GetEmbeddedFiles() } );
211
212 wxString msg;
213
214 if( !DS_DATA_MODEL::GetTheInstance().LoadDrawingSheet( filename, &msg ) )
215 {
216 wxFprintf( stderr, _( "Error loading drawing sheet '%s': %s" ),
218 }
219
220 // JEY TODO: move this global to the board
222
223 layerEnum.Choices().Clear();
224 layerEnum.Undefined( UNDEFINED_LAYER );
225
226 for( PCB_LAYER_ID layer : LSET::AllLayersMask() )
227 {
228 // Canonical name
229 layerEnum.Map( layer, LSET::Name( layer ) );
230
231 // User name
232 layerEnum.Map( layer, brd->GetLayerName( layer ) );
233 }
234
235 brd->SetProject( project );
236
237 // Move legacy view settings to local project settings
238 if( !brd->m_LegacyVisibleLayers.test( Rescue ) )
239 project->GetLocalSettings().m_VisibleLayers = brd->m_LegacyVisibleLayers;
240
242 project->GetLocalSettings().m_VisibleItems = brd->m_LegacyVisibleItems;
243
245 bds.m_DRCEngine = std::make_shared<DRC_ENGINE>( brd, &bds );
246
247 try
248 {
249 wxFileName rules = pro;
250 rules.SetExt( FILEEXT::DesignRulesFileExtension );
251 bds.m_DRCEngine->InitEngine( rules );
252 }
253 catch( ... )
254 {
255 // Best efforts...
256 }
257
258 for( PCB_MARKER* marker : brd->ResolveDRCExclusions( true ) )
259 brd->Add( marker );
260
261 brd->BuildConnectivity();
262 brd->BuildListOfNets();
263 brd->SynchronizeNetsAndNetClasses( true );
264 brd->UpdateUserUnits( brd, nullptr );
265 }
266
267 return brd;
268}
269
270
271BOARD* NewBoard( wxString& aFileName )
272{
273 wxFileName boardFn = aFileName;
274 wxFileName proFn = aFileName;
275 proFn.SetExt( FILEEXT::ProjectFileExtension );
276 proFn.MakeAbsolute();
277
278 wxString projectPath = proFn.GetFullPath();
279
280 GetSettingsManager()->LoadProject( projectPath, false );
281 PROJECT* project = GetSettingsManager()->GetProject( projectPath );
282
283 BOARD* brd = new BOARD();
284
285 brd->SetProject( project );
287 bds.m_DRCEngine = std::make_shared<DRC_ENGINE>( brd, &bds );
288
289 SaveBoard( aFileName, brd );
290
291 return brd;
292}
293
294
296{
297 // Creating a new board is not possible if running inside KiCad
298 if( s_PcbEditFrame )
299 return nullptr;
300
301 BOARD* brd = new BOARD();
302
304
305 return brd;
306}
307
308
309bool SaveBoard( wxString& aFileName, BOARD* aBoard, PCB_IO_MGR::PCB_FILE_T aFormat, bool aSkipSettings )
310{
311 aBoard->BuildConnectivity();
312 aBoard->SynchronizeNetsAndNetClasses( false );
313
314 try
315 {
316 PCB_IO_MGR::Save( aFormat, aFileName, aBoard, nullptr );
317 }
318 catch( ... )
319 {
320 return false;
321 }
322
323 if( !aSkipSettings )
324 {
325 wxFileName pro = aFileName;
326 pro.SetExt( FILEEXT::ProjectFileExtension );
327 pro.MakeAbsolute();
328
329 GetSettingsManager()->SaveProjectAs( pro.GetFullPath(), aBoard->GetProject() );
330 }
331
332 return true;
333}
334
335
336bool SaveBoard( wxString& aFileName, BOARD* aBoard, bool aSkipSettings )
337{
338 return SaveBoard( aFileName, aBoard, PCB_IO_MGR::KICAD_SEXP, aSkipSettings );
339}
340
341
343{
344 BOARD* board = GetBoard();
345
346 if( !board )
347 return nullptr;
348
349 PROJECT* project = board->GetProject();
350
351 if( !project )
352 return nullptr;
353
355}
356
357
359{
360 wxArrayString footprintLibraryNames;
361
363
364 if( !adapter )
365 return footprintLibraryNames;
366
367 for( const wxString& name : adapter->GetLibraryNames() )
368 footprintLibraryNames.Add( name );
369
370 return footprintLibraryNames;
371}
372
373
374wxArrayString GetFootprints( const wxString& aNickName )
375{
376 wxArrayString footprintNames;
377
379
380 if( !adapter )
381 return footprintNames;
382
383 std::vector<wxString> names = adapter->GetFootprintNames( aNickName, true );
384 footprintNames.assign( names.begin(), names.end() );
385
386 return footprintNames;
387}
388
389
390bool ExportSpecctraDSN( wxString& aFullFilename )
391{
392 if( s_PcbEditFrame )
393 {
394 bool ok = s_PcbEditFrame->ExportSpecctraFile( aFullFilename );
395 return ok;
396 }
397 else
398 {
399 return false;
400 }
401}
402
403
404bool ExportSpecctraDSN( BOARD* aBoard, wxString& aFullFilename )
405{
406 try
407 {
408 DSN::ExportBoardToSpecctraFile( aBoard, aFullFilename );
409 }
410 catch( ... )
411 {
412 return false;
413 }
414
415 return true;
416}
417
418
419bool ExportVRML( const wxString& aFullFileName, double aMMtoWRMLunit, bool aIncludeUnspecified,
420 bool aIncludeDNP, bool aExport3DFiles,
421 bool aUseRelativePaths, const wxString& a3D_Subdir, double aXRef, double aYRef )
422{
423 if( s_PcbEditFrame )
424 {
425 bool ok = s_PcbEditFrame->ExportVRML_File( aFullFileName, aMMtoWRMLunit,
426 aIncludeUnspecified, aIncludeDNP,
427 aExport3DFiles, aUseRelativePaths,
428 a3D_Subdir, aXRef, aYRef );
429 return ok;
430 }
431 else
432 {
433 return false;
434 }
435}
436
437bool ImportSpecctraSES( wxString& aFullFilename )
438{
439 if( s_PcbEditFrame )
440 {
441 bool ok = s_PcbEditFrame->ImportSpecctraSession( aFullFilename );
442 return ok;
443 }
444 else
445 {
446 return false;
447 }
448}
449
450bool ImportSpecctraSES( BOARD* aBoard, wxString& aFullFilename )
451{
452 try
453 {
454 DSN::ImportSpecctraSession( aBoard, aFullFilename );
455 }
456 catch( ... )
457 {
458 return false;
459 }
460
461 return true;
462}
463
464
465bool ExportFootprintsToLibrary( bool aStoreInNewLib, const wxString& aLibName, wxString* aLibPath )
466{
467 if( s_PcbEditFrame )
468 {
469 s_PcbEditFrame->ExportFootprintsToLibrary( aStoreInNewLib, aLibName, aLibPath );
470 return true;
471 }
472 else
473 {
474 return false;
475 }
476}
477
479{
480 if( s_PcbEditFrame )
481 {
482 s_PcbEditFrame->RebuildAndRefresh();
483 }
484}
485
486
488{
489 if( s_PcbEditFrame )
490 s_PcbEditFrame->UpdateUserInterface();
491}
492
493
495{
496 if( s_PcbEditFrame )
497 return static_cast<int>( s_PcbEditFrame->GetUserUnits() );
498
499 return -1;
500}
501
502
503std::deque<BOARD_ITEM*> GetCurrentSelection()
504{
505 std::deque<BOARD_ITEM*> items;
506
507 if( s_PcbEditFrame )
508 {
509 SELECTION& selection = s_PcbEditFrame->GetCurrentSelection();
510
511 std::for_each( selection.begin(), selection.end(),
512 [&items]( EDA_ITEM* item )
513 {
514 if( item->IsBOARD_ITEM() )
515 items.push_back( static_cast<BOARD_ITEM*>( item ) );
516 } );
517 }
518
519 return items;
520}
521
522void FocusOnItem( BOARD_ITEM* aItem, PCB_LAYER_ID aLayer )
523{
524 if( s_PcbEditFrame )
525 {
526 s_PcbEditFrame->FocusOnItem( aItem, aLayer );
527 }
528}
529
530
535
536
537bool WriteDRCReport( BOARD* aBoard, const wxString& aFileName, EDA_UNITS aUnits,
538 bool aReportAllTrackErrors )
539{
540 wxCHECK( aBoard, false );
541
543 std::shared_ptr<DRC_ENGINE> engine = bds.m_DRCEngine;
544 UNITS_PROVIDER unitsProvider( pcbIUScale, aUnits );
545
546 if( !engine )
547 {
548 bds.m_DRCEngine = std::make_shared<DRC_ENGINE>( aBoard, &bds );
549 engine = bds.m_DRCEngine;
550 }
551
552 wxCHECK( engine, false );
553
554 wxFileName fn = aBoard->GetFileName();
556 PROJECT* prj = nullptr;
557
558 if( aBoard->GetProject() )
559 prj = aBoard->GetProject();
560 else if( s_SettingsManager )
561 prj = &s_SettingsManager->Prj();
562
563 wxCHECK( prj, false );
564
565 wxString drcRulesPath = prj->AbsolutePath( fn.GetFullName() );
566
567 // Rebuild The Instance of ENUM_MAP<PCB_LAYER_ID> (layer names list), because the DRC
568 // engine can use layer names (canonical and/or user names)
570 layerEnum.Choices().Clear();
571 layerEnum.Undefined( UNDEFINED_LAYER );
572
573 for( PCB_LAYER_ID layer : LSET::AllLayersMask() )
574 {
575 layerEnum.Map( layer, LSET::Name( layer ) ); // Add Canonical name
576 layerEnum.Map( layer, aBoard->GetLayerName( layer ) ); // Add User name
577 }
578
579 try
580 {
581 engine->InitEngine( drcRulesPath );
582 }
583 catch( PARSE_ERROR& err )
584 {
585 fprintf( stderr, "Init DRC engine: err <%s>\n", TO_UTF8( err.What() ) ); fflush( stderr);
586 return false;
587 }
588
589 std::vector<std::shared_ptr<DRC_ITEM>> footprints;
590 std::vector<std::shared_ptr<DRC_ITEM>> unconnected;
591 std::vector<std::shared_ptr<DRC_ITEM>> violations;
592
593 engine->SetProgressReporter( nullptr );
594
595 engine->SetViolationHandler(
596 [&]( const std::shared_ptr<DRC_ITEM>& aItem, const VECTOR2D& aPos, int aLayer,
597 const std::function<void( PCB_MARKER* )>& aPathGenerator )
598 {
599 if( aItem->GetErrorCode() == DRCE_MISSING_FOOTPRINT
600 || aItem->GetErrorCode() == DRCE_DUPLICATE_FOOTPRINT
601 || aItem->GetErrorCode() == DRCE_EXTRA_FOOTPRINT
602 || aItem->GetErrorCode() == DRCE_NET_CONFLICT
603 || aItem->GetErrorCode() == DRCE_SCHEMATIC_PARITY
604 || aItem->GetErrorCode() == DRCE_SCHEMATIC_FIELDS_PARITY
605 || aItem->GetErrorCode() == DRCE_FOOTPRINT_FILTERS )
606 {
607 footprints.push_back( aItem );
608 }
609 else if( aItem->GetErrorCode() == DRCE_UNCONNECTED_ITEMS )
610 {
611 unconnected.push_back( aItem );
612 }
613 else
614 {
615 violations.push_back( aItem );
616 }
617 } );
618
619 aBoard->RecordDRCExclusions();
620 aBoard->DeleteMARKERs( true, true );
621 engine->RunTests( aUnits, aReportAllTrackErrors, false );
622 engine->ClearViolationHandler();
623
624 // Update the exclusion status on any excluded markers that still exist.
625 aBoard->ResolveDRCExclusions( false );
626
627 // TODO: Unify this with DIALOG_DRC::writeReport
628
629 FILE* fp = wxFopen( aFileName, wxT( "w" ) );
630
631 if( fp == nullptr )
632 return false;
633
634 std::map<KIID, EDA_ITEM*> itemMap;
635 aBoard->FillItemMap( itemMap );
636
637 fprintf( fp, "** Drc report for %s **\n", TO_UTF8( aBoard->GetFileName() ) );
638
639 wxDateTime now = wxDateTime::Now();
640
641 fprintf( fp, "** Created on %s **\n", TO_UTF8( now.Format( wxT( "%F %T" ) ) ) );
642
643 fprintf( fp, "\n** Found %d DRC violations **\n", static_cast<int>( violations.size() ) );
644
645 for( const std::shared_ptr<DRC_ITEM>& item : violations )
646 {
647 SEVERITY severity = item->GetParent() ? item->GetParent()->GetSeverity()
648 : bds.GetSeverity( item->GetErrorCode() );
649 fprintf( fp, "%s", TO_UTF8( item->ShowReport( &unitsProvider, severity, itemMap ) ) );
650 }
651
652 fprintf( fp, "\n** Found %d unconnected pads **\n", static_cast<int>( unconnected.size() ) );
653
654 for( const std::shared_ptr<DRC_ITEM>& item : unconnected )
655 {
656 SEVERITY severity = bds.GetSeverity( item->GetErrorCode() );
657 fprintf( fp, "%s", TO_UTF8( item->ShowReport( &unitsProvider, severity, itemMap ) ) );
658 }
659
660 fprintf( fp, "\n** Found %d Footprint errors **\n", static_cast<int>( footprints.size() ) );
661
662 for( const std::shared_ptr<DRC_ITEM>& item : footprints )
663 {
664 SEVERITY severity = bds.GetSeverity( item->GetErrorCode() );
665 fprintf( fp, "%s", TO_UTF8( item->ShowReport( &unitsProvider, severity, itemMap ) ) );
666 }
667
668 fprintf( fp, "\n** End of Report **\n" );
669 fclose( fp );
670
671 return true;
672}
673
674wxString GetLanguage()
675{
676 if( s_PcbEditFrame )
678 else
679 return "";
680}
const char * name
Class PCBNEW_ACTION_PLUGINS.
constexpr EDA_IU_SCALE pcbIUScale
Definition base_units.h:112
static bool IsActionRunning()
static wxString m_DrawingSheetFileName
the name of the drawing sheet file, or empty to use the default drawing sheet
Definition base_screen.h:85
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...
Definition board_item.h:84
Information pertinent to a Pcbnew printed circuit board.
Definition board.h:322
void Add(BOARD_ITEM *aItem, ADD_MODE aMode=ADD_MODE::INSERT, bool aSkipConnectivity=false) override
Removes an item from the container.
Definition board.cpp:1223
GAL_SET m_LegacyVisibleItems
Definition board.h:433
void BuildListOfNets()
Definition board.h:959
void UpdateUserUnits(BOARD_ITEM *aItem, KIGFX::VIEW *aView)
Update any references within aItem (or its descendants) to the user units.
Definition board.cpp:1697
bool BuildConnectivity(PROGRESS_REPORTER *aReporter=nullptr)
Build or rebuild the board connectivity database for the board, especially the list of connected item...
Definition board.cpp:191
void RecordDRCExclusions()
Scan existing markers and record data from any that are Excluded.
Definition board.cpp:330
void SynchronizeNetsAndNetClasses(bool aResetTrackAndViaSizes)
Copy NETCLASS info to each NET, based on NET membership in a NETCLASS.
Definition board.cpp:2681
LSET m_LegacyVisibleLayers
Visibility settings stored in board prior to 6.0, only used for loading legacy files.
Definition board.h:432
void SetProject(PROJECT *aProject, bool aReferenceOnly=false)
Link a board to a given project.
Definition board.cpp:201
const wxString & GetFileName() const
Definition board.h:359
std::vector< PCB_MARKER * > ResolveDRCExclusions(bool aCreateMarkers)
Rebuild DRC markers from the serialized data in BOARD_DESIGN_SETTINGS.
Definition board.cpp:387
void FillItemMap(std::map< KIID, EDA_ITEM * > &aMap)
Definition board.cpp:1905
const wxString GetLayerName(PCB_LAYER_ID aLayer) const
Return the name of a aLayer.
Definition board.cpp:729
PROJECT * GetProject() const
Definition board.h:579
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Definition board.cpp:1083
void DeleteMARKERs()
Delete all MARKERS from the board.
Definition board.cpp:1719
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.
Definition eda_item.h:99
ENUM_MAP & Map(T aValue, const wxString &aName)
Definition property.h:727
static ENUM_MAP< T > & Instance()
Definition property.h:721
ENUM_MAP & Undefined(T aValue)
Definition property.h:734
wxPGChoices & Choices()
Definition property.h:770
Provide an extensible class to resolve 3D model paths.
An interface to the global shared library manager that is schematic-specific and linked to one projec...
std::vector< wxString > GetFootprintNames(const wxString &aNickname, bool aBestEfforts=false)
Retrieves a list of footprint names contained in a given loaded library.
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()
Definition lset.cpp:641
static wxString Name(PCB_LAYER_ID aLayerId)
Return the fixed name association with aLayerId.
Definition lset.cpp:188
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,...
Definition pcb_io_mgr.h:56
@ KICAD_SEXP
S-expression Pcbnew file format.
Definition pcb_io_mgr.h:58
@ LEGACY
Legacy Pcbnew file formats prior to s-expression.
Definition pcb_io_mgr.h:59
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,...
virtual SETTINGS_MANAGER & GetSettingsManager() const
Definition pgm_base.h:131
static FOOTPRINT_LIBRARY_ADAPTER * FootprintLibAdapter(PROJECT *aProject)
Container for project specific data.
Definition project.h:65
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.
Definition project.cpp:401
ITER end()
Definition selection.h:80
ITER begin()
Definition selection.h:79
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.
PROJECT & Prj() const
A helper while we are not MDI-capable – return the one and only project.
@ DRCE_FOOTPRINT_FILTERS
Definition drc_item.h:80
@ DRCE_UNCONNECTED_ITEMS
Definition drc_item.h:40
@ DRCE_SCHEMATIC_FIELDS_PARITY
Definition drc_item.h:120
@ DRCE_DUPLICATE_FOOTPRINT
Definition drc_item.h:76
@ DRCE_EXTRA_FOOTPRINT
Definition drc_item.h:77
@ DRCE_NET_CONFLICT
Definition drc_item.h:78
@ DRCE_MISSING_FOOTPRINT
Definition drc_item.h:75
@ DRCE_SCHEMATIC_PARITY
Definition drc_item.h:79
#define _(s)
EDA_UNITS
Definition eda_units.h:48
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 &)
Definition ignore.h:24
@ GAL_LAYER_ID_BITMASK_END
This is the end of the layers used for visibility bit masks in legacy board files.
Definition layer_ids.h:287
PCB_LAYER_ID
A quick note on layer IDs:
Definition layer_ids.h:60
@ UNDEFINED_LAYER
Definition layer_ids.h:61
@ Rescue
Definition layer_ids.h:121
#define GAL_LAYER_INDEX(x)
Use this macro to convert a GAL layer to a 0-indexed offset from LAYER_VIAS.
Definition layer_ids.h:364
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
BOARD * GetBoard()
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 & Pgm()
The global program "get" accessor.
PGM_BASE * PgmOrNull()
Return a reference that can be nullptr when running a shared lib from a script, not from a kicad app.
see class PGM_BASE
SEVERITY
#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 vector2d.h:694
Definition of file extensions used in Kicad.