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 (C) 1992-2023 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
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>
38#include <pcb_marker.h>
39#include <cstdlib>
41#include <drc/drc_engine.h>
42#include <drc/drc_item.h>
43#include <fp_lib_table.h>
44#include <core/ignore.h>
45#include <io_mgr.h>
46#include <string_utils.h>
47#include <macros.h>
49#include <project.h>
50#include <project_pcb.h>
54#include <specctra.h>
57#include <locale_io.h>
58#include <wx/app.h>
59#include <wx/crt.h>
60
61
64
65
67{
68 if( s_PcbEditFrame )
69 return s_PcbEditFrame->GetBoard();
70 else
71 return nullptr;
72}
73
74
76{
77 s_PcbEditFrame = aPcbEditFrame;
78}
79
80
82{
83 if( s_PcbEditFrame == aPcbEditFrame )
84 s_PcbEditFrame = nullptr;
85}
86
87BOARD* LoadBoard( wxString& aFileName )
88{
89 if( aFileName.EndsWith( KiCadPcbFileExtension ) )
90 return LoadBoard( aFileName, IO_MGR::KICAD_SEXP );
91 else if( aFileName.EndsWith( LegacyPcbFileExtension ) )
92 return LoadBoard( aFileName, IO_MGR::LEGACY );
93
94 // as fall back for any other kind use the legacy format
95 return LoadBoard( aFileName, IO_MGR::LEGACY );
96}
97
98
100{
101 if( !s_SettingsManager )
102 {
103 if( s_PcbEditFrame )
104 {
106 }
107 else
108 {
109 // Ensure wx system settings stuff is available
110 ignore_unused( wxTheApp );
112 }
113 }
114
115 return s_SettingsManager;
116}
117
118
120{
121 // For some reasons, LoadProject() needs a C locale, so ensure we have the right locale
122 // This is mainly when running QA Python tests
124
126
127 if( !project )
128 {
131 }
132
133 return project;
134}
135
136
137BOARD* LoadBoard( wxString& aFileName, IO_MGR::PCB_FILE_T aFormat )
138{
139 wxFileName pro = aFileName;
140 pro.SetExt( ProjectFileExtension );
141 pro.MakeAbsolute();
142 wxString projectPath = pro.GetFullPath();
143
144 // Ensure the "C" locale is temporary set, before reading any file
145 // It also avoid wxWidget alerts about locale issues, later, when using Python 3
147
148 PROJECT* project = GetSettingsManager()->GetProject( projectPath );
149
150 if( !project )
151 {
152 if( wxFileExists( projectPath ) )
153 {
154 GetSettingsManager()->LoadProject( projectPath, false );
155 project = GetSettingsManager()->GetProject( projectPath );
156 }
157 }
158 else if( s_PcbEditFrame && project == &GetSettingsManager()->Prj() )
159 {
160 // Project is already loaded? Then so is the board
161 return s_PcbEditFrame->GetBoard();
162 }
163
164 // Board cannot be loaded without a project, so create the default project
165 if( !project )
167
168 BASE_SCREEN::m_DrawingSheetFileName = project->GetProjectFile().m_BoardDrawingSheetFile;
169
170 // Load the drawing sheet from the filename stored in BASE_SCREEN::m_DrawingSheetFileName.
171 // If empty, or not existing, the default drawing sheet is loaded.
173 project->GetProjectPath() );
174
175 if( !DS_DATA_MODEL::GetTheInstance().LoadDrawingSheet( filename ) )
176 wxFprintf( stderr, _( "Error loading drawing sheet." ) );
177
178 BOARD* brd = IO_MGR::Load( aFormat, aFileName );
179
180 if( brd )
181 {
182 brd->SetProject( project );
183
184 // Move legacy view settings to local project settings
185 if( !brd->m_LegacyVisibleLayers.test( Rescue ) )
186 project->GetLocalSettings().m_VisibleLayers = brd->m_LegacyVisibleLayers;
187
189 project->GetLocalSettings().m_VisibleItems = brd->m_LegacyVisibleItems;
190
192 bds.m_DRCEngine = std::make_shared<DRC_ENGINE>( brd, &bds );
193
194 try
195 {
196 wxFileName rules = pro;
197 rules.SetExt( DesignRulesFileExtension );
198 bds.m_DRCEngine->InitEngine( rules );
199 }
200 catch( ... )
201 {
202 // Best efforts...
203 }
204
205 for( PCB_MARKER* marker : brd->ResolveDRCExclusions( true ) )
206 brd->Add( marker );
207
208 brd->BuildConnectivity();
209 brd->BuildListOfNets();
210 brd->SynchronizeNetsAndNetClasses( false );
211 brd->UpdateUserUnits( brd, nullptr );
212 }
213
214 return brd;
215}
216
217
218BOARD* NewBoard( wxString& aFileName )
219{
220 wxFileName boardFn = aFileName;
221 wxFileName proFn = aFileName;
222 proFn.SetExt( ProjectFileExtension );
223 proFn.MakeAbsolute();
224
225 wxString projectPath = proFn.GetFullPath();
226
227 // Ensure the "C" locale is temporary set, before reading any file
228 // It also avoids wxWidgets alerts about locale issues, later, when using Python 3
230
231 GetSettingsManager()->LoadProject( projectPath, false );
232 PROJECT* project = GetSettingsManager()->GetProject( projectPath );
233
234 BOARD* brd = new BOARD();
235
236 brd->SetProject( project );
238 bds.m_DRCEngine = std::make_shared<DRC_ENGINE>( brd, &bds );
239
240 SaveBoard( aFileName, brd );
241
242 return brd;
243}
244
245
247{
248 // Creating a new board is not possible if running inside KiCad
249 if( s_PcbEditFrame )
250 return nullptr;
251
252 BOARD* brd = new BOARD();
253
255
256 return brd;
257}
258
259
260bool SaveBoard( wxString& aFileName, BOARD* aBoard, IO_MGR::PCB_FILE_T aFormat, bool aSkipSettings )
261{
262 aBoard->BuildConnectivity();
263 aBoard->SynchronizeNetsAndNetClasses( false );
264
265 // Ensure the "C" locale is temporary set, before saving any file
266 // It also avoid wxWidget alerts about locale issues, later, when using Python 3
268
269 try
270 {
271 IO_MGR::Save( aFormat, aFileName, aBoard, nullptr );
272 }
273 catch( ... )
274 {
275 return false;
276 }
277
278 if( !aSkipSettings )
279 {
280 wxFileName pro = aFileName;
281 pro.SetExt( ProjectFileExtension );
282 pro.MakeAbsolute();
283
284 GetSettingsManager()->SaveProjectAs( pro.GetFullPath(), aBoard->GetProject() );
285 }
286
287 return true;
288}
289
290
291bool SaveBoard( wxString& aFileName, BOARD* aBoard, bool aSkipSettings )
292{
293 return SaveBoard( aFileName, aBoard, IO_MGR::KICAD_SEXP, aSkipSettings );
294}
295
296
298{
299 BOARD* board = GetBoard();
300
301 if( !board )
302 return nullptr;
303
304 PROJECT* project = board->GetProject();
305
306 if( !project )
307 return nullptr;
308
310}
311
312
314{
315 wxArrayString footprintLibraryNames;
316
318
319 if( !tbl )
320 return footprintLibraryNames;
321
322 for( const wxString& name : tbl->GetLogicalLibs() )
323 footprintLibraryNames.Add( name );
324
325 return footprintLibraryNames;
326}
327
328
329wxArrayString GetFootprints( const wxString& aNickName )
330{
331 wxArrayString footprintNames;
332
334
335 if( !tbl )
336 return footprintNames;
337
338 tbl->FootprintEnumerate( footprintNames, aNickName, true );
339
340 return footprintNames;
341}
342
343
344bool ExportSpecctraDSN( wxString& aFullFilename )
345{
346 if( s_PcbEditFrame )
347 {
348 bool ok = s_PcbEditFrame->ExportSpecctraFile( aFullFilename );
349 return ok;
350 }
351 else
352 {
353 return false;
354 }
355}
356
357
358bool ExportSpecctraDSN( BOARD* aBoard, wxString& aFullFilename )
359{
360 try
361 {
362 DSN::ExportBoardToSpecctraFile( aBoard, aFullFilename );
363 }
364 catch( ... )
365 {
366 return false;
367 }
368
369 return true;
370}
371
372
373bool ExportVRML( const wxString& aFullFileName, double aMMtoWRMLunit, bool aExport3DFiles,
374 bool aUseRelativePaths, const wxString& a3D_Subdir, double aXRef, double aYRef )
375{
376 if( s_PcbEditFrame )
377 {
378 bool ok = s_PcbEditFrame->ExportVRML_File( aFullFileName, aMMtoWRMLunit,
379 aExport3DFiles, aUseRelativePaths,
380 a3D_Subdir, aXRef, aYRef );
381 return ok;
382 }
383 else
384 {
385 return false;
386 }
387}
388
389bool ImportSpecctraSES( wxString& aFullFilename )
390{
391 if( s_PcbEditFrame )
392 {
393 bool ok = s_PcbEditFrame->ImportSpecctraSession( aFullFilename );
394 return ok;
395 }
396 else
397 {
398 return false;
399 }
400}
401
402bool ImportSpecctraSES( BOARD* aBoard, wxString& aFullFilename )
403{
404 try
405 {
406 DSN::ImportSpecctraSession( aBoard, aFullFilename );
407 }
408 catch( ... )
409 {
410 return false;
411 }
412
413 return true;
414}
415
416
417bool ExportFootprintsToLibrary( bool aStoreInNewLib, const wxString& aLibName, wxString* aLibPath )
418{
419 if( s_PcbEditFrame )
420 {
421 s_PcbEditFrame->ExportFootprintsToLibrary( aStoreInNewLib, aLibName, aLibPath );
422 return true;
423 }
424 else
425 {
426 return false;
427 }
428}
429
431{
432 if( s_PcbEditFrame )
433 {
435 }
436}
437
438
440{
441 if( s_PcbEditFrame )
443}
444
445
447{
448 if( s_PcbEditFrame )
449 return static_cast<int>( s_PcbEditFrame->GetUserUnits() );
450
451 return -1;
452}
453
454
455std::deque<BOARD_ITEM*> GetCurrentSelection()
456{
457 std::deque<BOARD_ITEM*> items;
458
459 if( s_PcbEditFrame )
460 {
462
463 std::for_each( selection.begin(), selection.end(),
464 [&items]( EDA_ITEM* item )
465 {
466 items.push_back( static_cast<BOARD_ITEM*>( item ) );
467 } );
468 }
469
470 return items;
471}
472
473void FocusOnItem( BOARD_ITEM* aItem, PCB_LAYER_ID aLayer )
474{
475 if( s_PcbEditFrame )
476 {
477 s_PcbEditFrame->FocusOnItem( aItem, aLayer );
478 }
479}
480
481
483{
485}
486
487
488bool WriteDRCReport( BOARD* aBoard, const wxString& aFileName, EDA_UNITS aUnits,
489 bool aReportAllTrackErrors )
490{
491 wxCHECK( aBoard, false );
492
494 std::shared_ptr<DRC_ENGINE> engine = bds.m_DRCEngine;
495 UNITS_PROVIDER unitsProvider( pcbIUScale, aUnits );
496
497 if( !engine )
498 {
499 bds.m_DRCEngine = std::make_shared<DRC_ENGINE>( aBoard, &bds );
500 engine = bds.m_DRCEngine;
501 }
502
503 wxCHECK( engine, false );
504
505 wxFileName fn = aBoard->GetFileName();
506 fn.SetExt( DesignRulesFileExtension );
507 PROJECT* prj = nullptr;
508
509 if( aBoard->GetProject() )
510 prj = aBoard->GetProject();
511 else if( s_SettingsManager )
512 prj = &s_SettingsManager->Prj();
513
514 wxCHECK( prj, false );
515
516 // Load the global fp-lib-table otherwise we can't check the libs parity
517 wxFileName fn_flp = FP_LIB_TABLE::GetGlobalTableFileName();
518 if( fn_flp.FileExists() ) {
520 GFootprintTable.Load( fn_flp.GetFullPath() );
521 }
522
523 wxString drcRulesPath = prj->AbsolutePath( fn.GetFullName() );
524
525 // Rebuild The Instance of ENUM_MAP<PCB_LAYER_ID> (layer names list), because the DRC
526 // engine can use layer names (canonical and/or user names)
528 layerEnum.Choices().Clear();
529 layerEnum.Undefined( UNDEFINED_LAYER );
530
531 for( LSEQ seq = LSET::AllLayersMask().Seq(); seq; ++seq )
532 {
533 layerEnum.Map( *seq, LSET::Name( *seq ) ); // Add Canonical name
534 layerEnum.Map( *seq, aBoard->GetLayerName( *seq ) ); // Add User name
535 }
536
537 try
538 {
539 engine->InitEngine( drcRulesPath );
540 }
541 catch( PARSE_ERROR& err )
542 {
543 fprintf( stderr, "Init DRC engine: err <%s>\n", TO_UTF8( err.What() ) ); fflush( stderr);
544 return false;
545 }
546
547 std::vector<std::shared_ptr<DRC_ITEM>> footprints;
548 std::vector<std::shared_ptr<DRC_ITEM>> unconnected;
549 std::vector<std::shared_ptr<DRC_ITEM>> violations;
550
551 engine->SetProgressReporter( nullptr );
552
553 engine->SetViolationHandler(
554 [&]( const std::shared_ptr<DRC_ITEM>& aItem, VECTOR2D aPos, int aLayer )
555 {
556 if( aItem->GetErrorCode() == DRCE_MISSING_FOOTPRINT
557 || aItem->GetErrorCode() == DRCE_DUPLICATE_FOOTPRINT
558 || aItem->GetErrorCode() == DRCE_EXTRA_FOOTPRINT
559 || aItem->GetErrorCode() == DRCE_NET_CONFLICT )
560 {
561 footprints.push_back( aItem );
562 }
563 else if( aItem->GetErrorCode() == DRCE_UNCONNECTED_ITEMS )
564 {
565 unconnected.push_back( aItem );
566 }
567 else
568 {
569 violations.push_back( aItem );
570 }
571 } );
572
573 engine->RunTests( aUnits, aReportAllTrackErrors, false );
574 engine->ClearViolationHandler();
575
576 // TODO: Unify this with DIALOG_DRC::writeReport
577
578 FILE* fp = wxFopen( aFileName, wxT( "w" ) );
579
580 if( fp == nullptr )
581 return false;
582
583 std::map<KIID, EDA_ITEM*> itemMap;
584 aBoard->FillItemMap( itemMap );
585
586 fprintf( fp, "** Drc report for %s **\n", TO_UTF8( aBoard->GetFileName() ) );
587
588 wxDateTime now = wxDateTime::Now();
589
590 fprintf( fp, "** Created on %s **\n", TO_UTF8( now.Format( wxT( "%F %T" ) ) ) );
591
592 fprintf( fp, "\n** Found %d DRC violations **\n", static_cast<int>( violations.size() ) );
593
594 for( const std::shared_ptr<DRC_ITEM>& item : violations )
595 {
596 SEVERITY severity = item->GetParent() ? item->GetParent()->GetSeverity()
597 : bds.GetSeverity( item->GetErrorCode() );
598 fprintf( fp, "%s", TO_UTF8( item->ShowReport( &unitsProvider, severity, itemMap ) ) );
599 }
600
601 fprintf( fp, "\n** Found %d unconnected pads **\n", static_cast<int>( unconnected.size() ) );
602
603 for( const std::shared_ptr<DRC_ITEM>& item : unconnected )
604 {
605 SEVERITY severity = bds.GetSeverity( item->GetErrorCode() );
606 fprintf( fp, "%s", TO_UTF8( item->ShowReport( &unitsProvider, severity, itemMap ) ) );
607 }
608
609 fprintf( fp, "\n** Found %d Footprint errors **\n", static_cast<int>( footprints.size() ) );
610
611 for( const std::shared_ptr<DRC_ITEM>& item : footprints )
612 {
613 SEVERITY severity = bds.GetSeverity( item->GetErrorCode() );
614 fprintf( fp, "%s", TO_UTF8( item->ShowReport( &unitsProvider, severity, itemMap ) ) );
615 }
616
617 fprintf( fp, "\n** End of Report **\n" );
618 fclose( fp );
619
620 return true;
621}
622
623wxString GetLanguage()
624{
625 if( s_PcbEditFrame )
627 else
628 return "";
629}
const char * name
Definition: DXF_plotter.cpp:57
Class PCBNEW_ACTION_PLUGINS.
constexpr EDA_IU_SCALE pcbIUScale
Definition: base_units.h:109
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:77
Information pertinent to a Pcbnew printed circuit board.
Definition: board.h:276
void Add(BOARD_ITEM *aItem, ADD_MODE aMode=ADD_MODE::INSERT, bool aSkipConnectivity=false) override
Removes an item from the container.
Definition: board.cpp:855
GAL_SET m_LegacyVisibleItems
Definition: board.h:356
void BuildListOfNets()
Definition: board.h:790
void UpdateUserUnits(BOARD_ITEM *aItem, KIGFX::VIEW *aView)
Update any references within aItem (or its descendants) to the user units.
Definition: board.cpp:1072
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:182
void SynchronizeNetsAndNetClasses(bool aResetTrackAndViaSizes)
Copy NETCLASS info to each NET, based on NET membership in a NETCLASS.
Definition: board.cpp:1775
LSET m_LegacyVisibleLayers
Visibility settings stored in board prior to 6.0, only used for loading legacy files.
Definition: board.h:355
void SetProject(PROJECT *aProject, bool aReferenceOnly=false)
Link a board to a given project.
Definition: board.cpp:192
const wxString & GetFileName() const
Definition: board.h:313
std::vector< PCB_MARKER * > ResolveDRCExclusions(bool aCreateMarkers)
Rebuild DRC markers from the serialized data in BOARD_DESIGN_SETTINGS.
Definition: board.cpp:320
void FillItemMap(std::map< KIID, EDA_ITEM * > &aMap)
Definition: board.cpp:1231
const wxString GetLayerName(PCB_LAYER_ID aLayer) const
Return the name of a aLayer.
Definition: board.cpp:536
PROJECT * GetProject() const
Definition: board.h:457
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Definition: board.cpp:766
static DS_DATA_MODEL & GetTheInstance()
static function: returns the instance of DS_DATA_MODEL used in the application
static const wxString ResolvePath(const wxString &aPath, const wxString &aProjectPath)
Resolve a path which might be project-relative or contain env variable references.
SETTINGS_MANAGER * GetSettingsManager() const
A base class for most all the KiCad significant classes used in schematics and boards.
Definition: eda_item.h:85
ENUM_MAP & Map(T aValue, const wxString &aName)
Definition: property.h:646
static ENUM_MAP< T > & Instance()
Definition: property.h:640
ENUM_MAP & Undefined(T aValue)
Definition: property.h:653
wxPGChoices & Choices()
Definition: property.h:689
void FootprintEnumerate(wxArrayString &aFootprintNames, const wxString &aNickname, bool aBestEfforts)
Return a list of footprint names contained within the library given by aNickname.
static wxString GetGlobalTableFileName()
virtual const wxString What() const
A composite of Problem() and Where()
Definition: exceptions.cpp:30
PCB_FILE_T
The set of file types that the IO_MGR knows about, and for which there has been a plugin written,...
Definition: io_mgr.h:54
@ LEGACY
Legacy Pcbnew file formats prior to s-expression.
Definition: io_mgr.h:57
@ KICAD_SEXP
S-expression Pcbnew file format.
Definition: io_mgr.h:56
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::LoadBoard() function on it using the argume...
Definition: io_mgr.cpp:165
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,...
Definition: io_mgr.cpp:181
std::vector< wxString > GetLogicalLibs()
Return the logical library names, all of them that are pertinent to a look up done on this LIB_TABLE.
void Load(const wxString &aFileName)
Load the library table using the path defined by aFileName aFallBackTable.
void Clear()
Delete all rows.
Instantiate the current locale within a scope in which you are expecting exceptions to be thrown.
Definition: locale_io.h:49
LSEQ is a sequence (and therefore also a set) of PCB_LAYER_IDs.
Definition: layer_ids.h:513
static LSET AllLayersMask()
Definition: lset.cpp:817
static const wxChar * Name(PCB_LAYER_ID aLayerId)
Return the fixed name association with aLayerId.
Definition: lset.cpp:89
BOARD * GetBoard() const
void FocusOnItem(BOARD_ITEM *aItem, PCB_LAYER_ID aLayer=UNDEFINED_LAYER)
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.
static FP_LIB_TABLE * PcbFootprintLibs(PROJECT *aProject)
Return the table of footprint libraries without Kiway.
Definition: project_pcb.cpp:37
Container for project specific data.
Definition: project.h:62
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:328
ITER end()
Definition: selection.h:74
ITER begin()
Definition: selection.h:73
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...
COMMON_SETTINGS * GetCommonSettings() const
Retrieves the common settings shared by all applications.
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
FP_LIB_TABLE GFootprintTable
The global footprint library table.
Definition: cvpcb.cpp:134
@ DRCE_UNCONNECTED_ITEMS
Definition: drc_item.h:39
@ DRCE_DUPLICATE_FOOTPRINT
Definition: drc_item.h:71
@ DRCE_EXTRA_FOOTPRINT
Definition: drc_item.h:72
@ DRCE_NET_CONFLICT
Definition: drc_item.h:73
@ DRCE_MISSING_FOOTPRINT
Definition: drc_item.h:70
#define _(s)
EDA_UNITS
Definition: eda_units.h:46
const std::string LegacyPcbFileExtension
const std::string KiCadPcbFileExtension
const std::string ProjectFileExtension
const std::string DesignRulesFileExtension
void ignore_unused(const T &)
Definition: ignore.h:24
PROJECT & Prj()
Definition: kicad.cpp:576
@ 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:227
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:134
#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:265
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.
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.
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(wxString &aFileName)
SEVERITY
std::vector< FAB_LAYER_COLOR > dummy
#define TO_UTF8(wxstring)
Convert a wxString to a UTF8 encoded C string for all wxWidgets build modes.
Definition: string_utils.h:391
A filename or source description, a problem input line, a line number, a byte offset,...
Definition: ki_exception.h:120
Definition of file extensions used in Kicad.