KiCad PCB EDA Suite
Loading...
Searching...
No Matches
pcb_plugin.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 CERN
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
25#include <advanced_config.h>
26#include <board.h>
28#include <confirm.h>
29#include <convert_basic_shapes_to_polygon.h> // for enum RECT_CHAMFER_POSITIONS definition
30#include <string_utils.h>
31#include <kiface_base.h>
32#include <locale_io.h>
33#include <macros.h>
34#include <callback_gal.h>
35#include <pad.h>
36#include <footprint.h>
37#include <pcb_group.h>
38#include <pcb_shape.h>
39#include <pcb_dimension.h>
40#include <pcb_bitmap.h>
41#include <pcb_target.h>
42#include <pcb_text.h>
43#include <pcb_textbox.h>
44#include <pcb_track.h>
45#include <zone.h>
46#include <pcbnew_settings.h>
47#include <pgm_base.h>
50#include <trace_helpers.h>
51#include <progress_reporter.h>
53#include <wx/dir.h>
54#include <wx/ffile.h>
55#include <wx/log.h>
56
57// For some reason wxWidgets is built with wxUSE_BASE64 unset so expose the wxWidgets
58// base64 code. Needed for PCB_BITMAP
59#define wxUSE_BASE64 1
60#include <wx/base64.h>
61#include <wx/mstream.h>
62#include <filter_reader.h>
63
64
65using namespace PCB_KEYS_T;
66
67
68FP_CACHE_ITEM::FP_CACHE_ITEM( FOOTPRINT* aFootprint, const WX_FILENAME& aFileName ) :
69 m_filename( aFileName ),
70 m_footprint( aFootprint )
71{ }
72
73
74FP_CACHE::FP_CACHE( PCB_PLUGIN* aOwner, const wxString& aLibraryPath )
75{
76 m_owner = aOwner;
77 m_lib_raw_path = aLibraryPath;
78 m_lib_path.SetPath( aLibraryPath );
80 m_cache_dirty = true;
81}
82
83
84void FP_CACHE::Save( FOOTPRINT* aFootprint )
85{
87
88 if( !m_lib_path.DirExists() && !m_lib_path.Mkdir() )
89 {
90 THROW_IO_ERROR( wxString::Format( _( "Cannot create footprint library '%s'." ),
92 }
93
94 if( !m_lib_path.IsDirWritable() )
95 {
96 THROW_IO_ERROR( wxString::Format( _( "Footprint library '%s' is read only." ),
98 }
99
100 for( FP_CACHE_FOOTPRINT_MAP::iterator it = m_footprints.begin(); it != m_footprints.end(); ++it )
101 {
102 if( aFootprint && aFootprint != it->second->GetFootprint() )
103 continue;
104
105 WX_FILENAME fn = it->second->GetFileName();
106
107 wxString tempFileName =
108#ifdef USE_TMP_FILE
109 wxFileName::CreateTempFileName( fn.GetPath() );
110#else
111 fn.GetFullPath();
112#endif
113 // Allow file output stream to go out of scope to close the file stream before
114 // renaming the file.
115 {
116 wxLogTrace( traceKicadPcbPlugin, wxT( "Creating temporary library file '%s'." ),
117 tempFileName );
118
119 FILE_OUTPUTFORMATTER formatter( tempFileName );
120
121 m_owner->SetOutputFormatter( &formatter );
122 m_owner->Format( (BOARD_ITEM*) it->second->GetFootprint() );
123 }
124
125#ifdef USE_TMP_FILE
126 wxRemove( fn.GetFullPath() ); // it is not an error if this does not exist
127
128 // Even on Linux you can see an _intermittent_ error when calling wxRename(),
129 // and it is fully inexplicable. See if this dodges the error.
130 wxMilliSleep( 250L );
131
132 // Preserve the permissions of the current file
134
135 if( !wxRenameFile( tempFileName, fn.GetFullPath() ) )
136 {
137 wxString msg = wxString::Format( _( "Cannot rename temporary file '%s' to '%s'" ),
138 tempFileName,
139 fn.GetFullPath() );
140 THROW_IO_ERROR( msg );
141 }
142#endif
144 }
145
146 m_cache_timestamp += m_lib_path.GetModificationTime().GetValue().GetValue();
147
148 // If we've saved the full cache, we clear the dirty flag.
149 if( !aFootprint )
150 m_cache_dirty = false;
151}
152
153
155{
156 m_cache_dirty = false;
158
159 wxDir dir( m_lib_raw_path );
160
161 if( !dir.IsOpened() )
162 {
163 wxString msg = wxString::Format( _( "Footprint library '%s' not found." ),
165 THROW_IO_ERROR( msg );
166 }
167
168 wxString fullName;
169 wxString fileSpec = wxT( "*." ) + KiCadFootprintFileExtension;
170
171 // wxFileName construction is egregiously slow. Construct it once and just swap out
172 // the filename thereafter.
173 WX_FILENAME fn( m_lib_raw_path, wxT( "dummyName" ) );
174
175 if( dir.GetFirst( &fullName, fileSpec ) )
176 {
177 wxString cacheError;
178
179 do
180 {
181 fn.SetFullName( fullName );
182
183 // Queue I/O errors so only files that fail to parse don't get loaded.
184 try
185 {
186 FILE_LINE_READER reader( fn.GetFullPath() );
187 PCB_PARSER parser( &reader, nullptr, nullptr );
188
189 FOOTPRINT* footprint = dynamic_cast<FOOTPRINT*>( parser.Parse() );
190 wxString fpName = fn.GetName();
191
192 if( !footprint )
193 {
194 THROW_IO_ERROR( wxString::Format( _( "Unable to read file '%s'" ),
195 fn.GetFullPath() ) );
196 }
197
198 footprint->SetFPID( LIB_ID( wxEmptyString, fpName ) );
199 m_footprints.insert( fpName, new FP_CACHE_ITEM( footprint, fn ) );
200 }
201 catch( const IO_ERROR& ioe )
202 {
203 if( !cacheError.IsEmpty() )
204 cacheError += wxT( "\n\n" );
205
206 cacheError += ioe.What();
207 }
208 } while( dir.GetNext( &fullName ) );
209
211
212 if( !cacheError.IsEmpty() )
213 THROW_IO_ERROR( cacheError );
214 }
215}
216
217
218void FP_CACHE::Remove( const wxString& aFootprintName )
219{
220 FP_CACHE_FOOTPRINT_MAP::const_iterator it = m_footprints.find( aFootprintName );
221
222 if( it == m_footprints.end() )
223 {
224 wxString msg = wxString::Format( _( "Library '%s' has no footprint '%s'." ),
226 aFootprintName );
227 THROW_IO_ERROR( msg );
228 }
229
230 // Remove the footprint from the cache and delete the footprint file from the library.
231 wxString fullPath = it->second->GetFileName().GetFullPath();
232 m_footprints.erase( aFootprintName );
233 wxRemoveFile( fullPath );
234}
235
236
237bool FP_CACHE::IsPath( const wxString& aPath ) const
238{
239 return aPath == m_lib_raw_path;
240}
241
242
243void FP_CACHE::SetPath( const wxString& aPath )
244{
245 m_lib_raw_path = aPath;
246 m_lib_path.SetPath( aPath );
247
248
249 for( const auto& footprint : GetFootprints() )
250 {
251 footprint.second->SetFilePath( aPath );
252 }
253}
254
255
257{
259
260 return m_cache_dirty;
261}
262
263
264long long FP_CACHE::GetTimestamp( const wxString& aLibPath )
265{
266 wxString fileSpec = wxT( "*." ) + KiCadFootprintFileExtension;
267
268 return TimestampDir( aLibPath, fileSpec );
269}
270
271
272bool PCB_PLUGIN::CanReadBoard( const wxString& aFileName ) const
273{
274 if( !PLUGIN::CanReadBoard( aFileName ) )
275 return false;
276
277 try
278 {
279 FILE_LINE_READER reader( aFileName );
280 PCB_PARSER parser( &reader, nullptr, m_queryUserCallback );
281
282 return parser.IsValidBoardHeader();
283 }
284 catch( const IO_ERROR& )
285 {
286 return false;
287 }
288
289 return false;
290}
291
292
293void PCB_PLUGIN::SaveBoard( const wxString& aFileName, BOARD* aBoard,
294 const STRING_UTF8_MAP* aProperties )
295{
296 LOCALE_IO toggle; // toggles on, then off, the C locale.
297
298 wxString sanityResult = aBoard->GroupsSanityCheck();
299
300 if( sanityResult != wxEmptyString && m_queryUserCallback )
301 {
303 _( "Internal Group Data Error" ), wxICON_ERROR,
304 wxString::Format( _( "Please report this bug. Error validating group "
305 "structure: %s\n\nSave anyway?" ), sanityResult ),
306 _( "Save Anyway" ) ) )
307 {
308 return;
309 }
310 }
311
312 init( aProperties );
313
314 m_board = aBoard; // after init()
315
316 // Prepare net mapping that assures that net codes saved in a file are consecutive integers
317 m_mapping->SetBoard( aBoard );
318
319 FILE_OUTPUTFORMATTER formatter( aFileName );
320
321 m_out = &formatter; // no ownership
322
323 m_out->Print( 0, "(kicad_pcb (version %d) (generator pcbnew)\n", SEXPR_BOARD_FILE_VERSION );
324
325 Format( aBoard, 1 );
326
327 m_out->Print( 0, ")\n" );
328
329 m_out = nullptr;
330}
331
332
333BOARD_ITEM* PCB_PLUGIN::Parse( const wxString& aClipboardSourceInput )
334{
335 std::string input = TO_UTF8( aClipboardSourceInput );
336
337 STRING_LINE_READER reader( input, wxT( "clipboard" ) );
338 PCB_PARSER parser( &reader, nullptr, m_queryUserCallback );
339
340 try
341 {
342 return parser.Parse();
343 }
344 catch( const PARSE_ERROR& parse_error )
345 {
346 if( parser.IsTooRecent() )
347 throw FUTURE_FORMAT_ERROR( parse_error, parser.GetRequiredVersion() );
348 else
349 throw;
350 }
351}
352
353
354void PCB_PLUGIN::Format( const BOARD_ITEM* aItem, int aNestLevel ) const
355{
356 LOCALE_IO toggle; // public API function, perform anything convenient for caller
357
358 switch( aItem->Type() )
359 {
360 case PCB_T:
361 format( static_cast<const BOARD*>( aItem ), aNestLevel );
362 break;
363
365 case PCB_DIM_CENTER_T:
366 case PCB_DIM_RADIAL_T:
368 case PCB_DIM_LEADER_T:
369 format( static_cast<const PCB_DIMENSION_BASE*>( aItem ), aNestLevel );
370 break;
371
372 case PCB_SHAPE_T:
373 format( static_cast<const PCB_SHAPE*>( aItem ), aNestLevel );
374 break;
375
376 case PCB_BITMAP_T:
377 format( static_cast<const PCB_BITMAP*>( aItem ), aNestLevel );
378 break;
379
380 case PCB_TARGET_T:
381 format( static_cast<const PCB_TARGET*>( aItem ), aNestLevel );
382 break;
383
384 case PCB_FOOTPRINT_T:
385 format( static_cast<const FOOTPRINT*>( aItem ), aNestLevel );
386 break;
387
388 case PCB_PAD_T:
389 format( static_cast<const PAD*>( aItem ), aNestLevel );
390 break;
391
392 case PCB_FIELD_T:
393 // Handled in the footprint formatter when properties are formatted
394 break;
395
396 case PCB_TEXT_T:
397 format( static_cast<const PCB_TEXT*>( aItem ), aNestLevel );
398 break;
399
400 case PCB_TEXTBOX_T:
401 format( static_cast<const PCB_TEXTBOX*>( aItem ), aNestLevel );
402 break;
403
404 case PCB_GROUP_T:
405 format( static_cast<const PCB_GROUP*>( aItem ), aNestLevel );
406 break;
407
408 case PCB_TRACE_T:
409 case PCB_ARC_T:
410 case PCB_VIA_T:
411 format( static_cast<const PCB_TRACK*>( aItem ), aNestLevel );
412 break;
413
414 case PCB_ZONE_T:
415 format( static_cast<const ZONE*>( aItem ), aNestLevel );
416 break;
417
418 default:
419 wxFAIL_MSG( wxT( "Cannot format item " ) + aItem->GetClass() );
420 }
421}
422
423
424std::string formatInternalUnits( int aValue )
425{
427}
428
429
430std::string formatInternalUnits( const VECTOR2I& aCoord )
431{
433}
434
435
436std::string formatInternalUnits( const VECTOR2I& aCoord, const FOOTPRINT* aParentFP )
437{
438 if( aParentFP )
439 {
440 VECTOR2I coord = aCoord - aParentFP->GetPosition();
441 RotatePoint( coord, -aParentFP->GetOrientation() );
442 return formatInternalUnits( coord );
443 }
444
445 return formatInternalUnits( aCoord );
446}
447
448
449void PCB_PLUGIN::formatLayer( PCB_LAYER_ID aLayer, bool aIsKnockout ) const
450{
451 m_out->Print( 0, " (layer %s%s)",
452 m_out->Quotew( LSET::Name( aLayer ) ).c_str(),
453 aIsKnockout ? " knockout" : "" );
454}
455
456
457void PCB_PLUGIN::formatPolyPts( const SHAPE_LINE_CHAIN& outline, int aNestLevel,
458 bool aCompact, const FOOTPRINT* aParentFP ) const
459{
460 m_out->Print( aNestLevel + 1, "(pts\n" );
461
462 bool needNewline = false;
463 int nestLevel = aNestLevel + 2;
464 int shapesAdded = 0;
465
466 for( int ii = 0; ii < outline.PointCount(); ++ii )
467 {
468 int ind = outline.ArcIndex( ii );
469
470 if( ind < 0 )
471 {
472 m_out->Print( nestLevel, "(xy %s)",
473 formatInternalUnits( outline.CPoint( ii ), aParentFP ).c_str() );
474 needNewline = true;
475 }
476 else
477 {
478 const SHAPE_ARC& arc = outline.Arc( ind );
479 m_out->Print( nestLevel, "(arc (start %s) (mid %s) (end %s))",
480 formatInternalUnits( arc.GetP0(), aParentFP ).c_str(),
481 formatInternalUnits( arc.GetArcMid(), aParentFP ).c_str(),
482 formatInternalUnits( arc.GetP1(), aParentFP ).c_str() );
483 needNewline = true;
484
485 do
486 {
487 ++ii;
488 } while( ii < outline.PointCount() && outline.ArcIndex( ii ) == ind );
489
490 --ii;
491 }
492
493 ++shapesAdded;
494
495 if( !( shapesAdded % 4 ) || !aCompact )
496 {
497 // newline every 4 shapes if compact save
498 m_out->Print( 0, "\n" );
499 needNewline = false;
500 }
501 }
502
503 if( needNewline )
504 m_out->Print( 0, "\n" );
505
506 m_out->Print( aNestLevel + 1, ")\n" );
507}
508
509
510void PCB_PLUGIN::formatRenderCache( const EDA_TEXT* aText, int aNestLevel ) const
511{
512 wxString resolvedText( aText->GetShownText( true ) );
513 std::vector<std::unique_ptr<KIFONT::GLYPH>>* cache = aText->GetRenderCache( aText->GetFont(),
514 resolvedText );
515
516 m_out->Print( aNestLevel, "(render_cache %s %s\n",
517 m_out->Quotew( resolvedText ).c_str(),
518 EDA_UNIT_UTILS::FormatAngle( aText->GetDrawRotation() ).c_str() );
519
521
522 CALLBACK_GAL callback_gal( empty_opts,
523 // Polygon callback
524 [&]( const SHAPE_LINE_CHAIN& aPoly )
525 {
526 m_out->Print( aNestLevel + 1, "(polygon\n" );
527 formatPolyPts( aPoly, aNestLevel + 1, true );
528 m_out->Print( aNestLevel + 1, ")\n" );
529 } );
530
531 callback_gal.SetLineWidth( aText->GetTextThickness() );
532 callback_gal.DrawGlyphs( *cache );
533
534 m_out->Print( aNestLevel, ")\n" );
535}
536
537
538void PCB_PLUGIN::formatSetup( const BOARD* aBoard, int aNestLevel ) const
539{
540 // Setup
541 m_out->Print( aNestLevel, "(setup\n" );
542
543 // Save the board physical stackup structure
544 const BOARD_STACKUP& stackup = aBoard->GetDesignSettings().GetStackupDescriptor();
545
546 if( aBoard->GetDesignSettings().m_HasStackup )
547 stackup.FormatBoardStackup( m_out, aBoard, aNestLevel+1 );
548
549 BOARD_DESIGN_SETTINGS& dsnSettings = aBoard->GetDesignSettings();
550
551 m_out->Print( aNestLevel+1, "(pad_to_mask_clearance %s)\n",
552 formatInternalUnits( dsnSettings.m_SolderMaskExpansion ).c_str() );
553
554 if( dsnSettings.m_SolderMaskMinWidth )
555 {
556 m_out->Print( aNestLevel+1, "(solder_mask_min_width %s)\n",
557 formatInternalUnits( dsnSettings.m_SolderMaskMinWidth ).c_str() );
558 }
559
560 if( dsnSettings.m_SolderPasteMargin != 0 )
561 {
562 m_out->Print( aNestLevel+1, "(pad_to_paste_clearance %s)\n",
563 formatInternalUnits( dsnSettings.m_SolderPasteMargin ).c_str() );
564 }
565
566 if( dsnSettings.m_SolderPasteMarginRatio != 0 )
567 {
568 m_out->Print( aNestLevel+1, "(pad_to_paste_clearance_ratio %s)\n",
569 FormatDouble2Str( dsnSettings.m_SolderPasteMarginRatio ).c_str() );
570 }
571
572 if( dsnSettings.m_AllowSoldermaskBridgesInFPs )
573 {
574 m_out->Print( aNestLevel+1, "(allow_soldermask_bridges_in_footprints yes)\n" );
575 }
576
577 VECTOR2I origin = dsnSettings.GetAuxOrigin();
578
579 if( origin != VECTOR2I( 0, 0 ) )
580 {
581 m_out->Print( aNestLevel+1, "(aux_axis_origin %s %s)\n",
582 formatInternalUnits( origin.x ).c_str(),
583 formatInternalUnits( origin.y ).c_str() );
584 }
585
586 origin = dsnSettings.GetGridOrigin();
587
588 if( origin != VECTOR2I( 0, 0 ) )
589 {
590 m_out->Print( aNestLevel+1, "(grid_origin %s %s)\n",
591 formatInternalUnits( origin.x ).c_str(),
592 formatInternalUnits( origin.y ).c_str() );
593 }
594
595 aBoard->GetPlotOptions().Format( m_out, aNestLevel+1 );
596
597 m_out->Print( aNestLevel, ")\n\n" );
598}
599
600
601void PCB_PLUGIN::formatGeneral( const BOARD* aBoard, int aNestLevel ) const
602{
603 const BOARD_DESIGN_SETTINGS& dsnSettings = aBoard->GetDesignSettings();
604
605 m_out->Print( 0, "\n" );
606 m_out->Print( aNestLevel, "(general\n" );
607
608 m_out->Print( aNestLevel+1, "(thickness %s)\n",
609 formatInternalUnits( dsnSettings.GetBoardThickness() ).c_str() );
610
611 if( aBoard->LegacyTeardrops() )
612 m_out->Print( aNestLevel+1, "(legacy_teardrops)\n" );
613
614 m_out->Print( aNestLevel, ")\n\n" );
615
616 aBoard->GetPageSettings().Format( m_out, aNestLevel, m_ctl );
617 aBoard->GetTitleBlock().Format( m_out, aNestLevel, m_ctl );
618}
619
620
621void PCB_PLUGIN::formatBoardLayers( const BOARD* aBoard, int aNestLevel ) const
622{
623 m_out->Print( aNestLevel, "(layers\n" );
624
625 // Save only the used copper layers from front to back.
626
627 for( LSEQ cu = aBoard->GetEnabledLayers().CuStack(); cu; ++cu )
628 {
629 PCB_LAYER_ID layer = *cu;
630
631 m_out->Print( aNestLevel+1, "(%d %s %s", layer,
632 m_out->Quotew( LSET::Name( layer ) ).c_str(),
633 LAYER::ShowType( aBoard->GetLayerType( layer ) ) );
634
635 if( LSET::Name( layer ) != m_board->GetLayerName( layer ) )
636 m_out->Print( 0, " %s", m_out->Quotew( m_board->GetLayerName( layer ) ).c_str() );
637
638 m_out->Print( 0, ")\n" );
639 }
640
641 // Save used non-copper layers in the order they are defined.
642 // desired sequence for non Cu BOARD layers.
643 static const PCB_LAYER_ID non_cu[] =
644 {
645 B_Adhes, // 32
646 F_Adhes,
647 B_Paste,
648 F_Paste,
649 B_SilkS,
650 F_SilkS,
651 B_Mask,
652 F_Mask,
653 Dwgs_User,
654 Cmts_User,
655 Eco1_User,
656 Eco2_User,
657 Edge_Cuts,
658 Margin,
659 B_CrtYd,
660 F_CrtYd,
661 B_Fab,
662 F_Fab,
663 User_1,
664 User_2,
665 User_3,
666 User_4,
667 User_5,
668 User_6,
669 User_7,
670 User_8,
671 User_9
672 };
673
674 for( LSEQ seq = aBoard->GetEnabledLayers().Seq( non_cu, arrayDim( non_cu ) ); seq; ++seq )
675 {
676 PCB_LAYER_ID layer = *seq;
677
678 m_out->Print( aNestLevel+1, "(%d %s user", layer,
679 m_out->Quotew( LSET::Name( layer ) ).c_str() );
680
681 if( m_board->GetLayerName( layer ) != LSET::Name( layer ) )
682 m_out->Print( 0, " %s", m_out->Quotew( m_board->GetLayerName( layer ) ).c_str() );
683
684 m_out->Print( 0, ")\n" );
685 }
686
687 m_out->Print( aNestLevel, ")\n\n" );
688}
689
690
691void PCB_PLUGIN::formatNetInformation( const BOARD* aBoard, int aNestLevel ) const
692{
693 for( NETINFO_ITEM* net : *m_mapping )
694 {
695 if( net == nullptr ) // Skip not actually existing nets (orphan nets)
696 continue;
697
698 m_out->Print( aNestLevel, "(net %d %s)\n",
699 m_mapping->Translate( net->GetNetCode() ),
700 m_out->Quotew( net->GetNetname() ).c_str() );
701 }
702
703 m_out->Print( 0, "\n" );
704}
705
706
707void PCB_PLUGIN::formatProperties( const BOARD* aBoard, int aNestLevel ) const
708{
709 for( const std::pair<const wxString, wxString>& prop : aBoard->GetProperties() )
710 {
711 m_out->Print( aNestLevel, "(property %s %s)\n",
712 m_out->Quotew( prop.first ).c_str(),
713 m_out->Quotew( prop.second ).c_str() );
714 }
715
716 if( !aBoard->GetProperties().empty() )
717 m_out->Print( 0, "\n" );
718}
719
720
721void PCB_PLUGIN::formatHeader( const BOARD* aBoard, int aNestLevel ) const
722{
723 formatGeneral( aBoard, aNestLevel );
724
725 // Layers list.
726 formatBoardLayers( aBoard, aNestLevel );
727
728 // Setup
729 formatSetup( aBoard, aNestLevel );
730
731 // Properties
732 formatProperties( aBoard, aNestLevel );
733
734 // Save net codes and names
735 formatNetInformation( aBoard, aNestLevel );
736}
737
738
740{
741 static const TEARDROP_PARAMETERS defaults;
742
743 return tdParams.m_Enabled == defaults.m_Enabled
744 && tdParams.m_BestLengthRatio == defaults.m_BestLengthRatio
745 && tdParams.m_TdMaxLen == defaults.m_TdMaxLen
746 && tdParams.m_BestWidthRatio == defaults.m_BestWidthRatio
747 && tdParams.m_TdMaxWidth == defaults.m_TdMaxWidth
748 && tdParams.m_CurveSegCount == defaults.m_CurveSegCount
750 && tdParams.m_AllowUseTwoTracks == defaults.m_AllowUseTwoTracks
751 && tdParams.m_TdOnPadsInZones == defaults.m_TdOnPadsInZones;
752}
753
754
756 int aNestLevel ) const
757{
758 m_out->Print( aNestLevel, "(teardrops%s%s%s (best_length_ratio %s) (max_length %s) "
759 "(best_width_ratio %s) (max_width %s) (curve_points %d) "
760 "(filter_ratio %s))\n",
761 tdParams.m_Enabled ? " enabled" : "",
762 tdParams.m_AllowUseTwoTracks ? " allow_two_segments" : "",
763 tdParams.m_TdOnPadsInZones ? " prefer_zone_connections" : "",
764 FormatDouble2Str( tdParams.m_BestLengthRatio ).c_str(),
765 formatInternalUnits( tdParams.m_TdMaxLen ).c_str(),
766 FormatDouble2Str( tdParams.m_BestWidthRatio ).c_str(),
767 formatInternalUnits( tdParams.m_TdMaxWidth ).c_str(),
768 tdParams.m_CurveSegCount,
769 FormatDouble2Str( tdParams.m_WidthtoSizeFilterRatio ).c_str() );
770}
771
772
773void PCB_PLUGIN::format( const BOARD* aBoard, int aNestLevel ) const
774{
775 std::set<BOARD_ITEM*, BOARD_ITEM::ptr_cmp> sorted_footprints( aBoard->Footprints().begin(),
776 aBoard->Footprints().end() );
777 std::set<BOARD_ITEM*, BOARD_ITEM::ptr_cmp> sorted_drawings( aBoard->Drawings().begin(),
778 aBoard->Drawings().end() );
779 std::set<PCB_TRACK*, PCB_TRACK::cmp_tracks> sorted_tracks( aBoard->Tracks().begin(),
780 aBoard->Tracks().end() );
781 std::set<BOARD_ITEM*, BOARD_ITEM::ptr_cmp> sorted_zones( aBoard->Zones().begin(),
782 aBoard->Zones().end() );
783 std::set<BOARD_ITEM*, BOARD_ITEM::ptr_cmp> sorted_groups( aBoard->Groups().begin(),
784 aBoard->Groups().end() );
785 formatHeader( aBoard, aNestLevel );
786
787 // Save the footprints.
788 for( BOARD_ITEM* footprint : sorted_footprints )
789 {
790 Format( footprint, aNestLevel );
791 m_out->Print( 0, "\n" );
792 }
793
794 // Save the graphical items on the board (not owned by a footprint)
795 for( BOARD_ITEM* item : sorted_drawings )
796 Format( item, aNestLevel );
797
798 if( sorted_drawings.size() )
799 m_out->Print( 0, "\n" );
800
801 // Do not save PCB_MARKERs, they can be regenerated easily.
802
803 // Save the tracks and vias.
804 for( PCB_TRACK* track : sorted_tracks )
805 Format( track, aNestLevel );
806
807 if( sorted_tracks.size() )
808 m_out->Print( 0, "\n" );
809
810 // Save the polygon (which are the newer technology) zones.
811 for( auto zone : sorted_zones )
812 Format( zone, aNestLevel );
813
814 // Save the groups
815 for( BOARD_ITEM* group : sorted_groups )
816 Format( group, aNestLevel );
817}
818
819
820void PCB_PLUGIN::format( const PCB_DIMENSION_BASE* aDimension, int aNestLevel ) const
821{
822 const PCB_DIM_ALIGNED* aligned = dynamic_cast<const PCB_DIM_ALIGNED*>( aDimension );
823 const PCB_DIM_ORTHOGONAL* ortho = dynamic_cast<const PCB_DIM_ORTHOGONAL*>( aDimension );
824 const PCB_DIM_CENTER* center = dynamic_cast<const PCB_DIM_CENTER*>( aDimension );
825 const PCB_DIM_RADIAL* radial = dynamic_cast<const PCB_DIM_RADIAL*>( aDimension );
826 const PCB_DIM_LEADER* leader = dynamic_cast<const PCB_DIM_LEADER*>( aDimension );
827
828 m_out->Print( aNestLevel, "(dimension" );
829
830 if( aDimension->IsLocked() )
831 m_out->Print( 0, " locked" );
832
833 if( ortho ) // must be tested before aligned, because ortho is derived from aligned
834 // and aligned is not null
835 m_out->Print( 0, " (type orthogonal)" );
836 else if( aligned )
837 m_out->Print( 0, " (type aligned)" );
838 else if( leader )
839 m_out->Print( 0, " (type leader)" );
840 else if( center )
841 m_out->Print( 0, " (type center)" );
842 else if( radial )
843 m_out->Print( 0, " (type radial)" );
844 else
845 wxFAIL_MSG( wxT( "Cannot format unknown dimension type!" ) );
846
847 formatLayer( aDimension->GetLayer() );
848
849 m_out->Print( 0, " (tstamp %s)", TO_UTF8( aDimension->m_Uuid.AsString() ) );
850
851 m_out->Print( 0, "\n" );
852
853 m_out->Print( aNestLevel+1, "(pts (xy %s %s) (xy %s %s))\n",
854 formatInternalUnits( aDimension->GetStart().x ).c_str(),
855 formatInternalUnits( aDimension->GetStart().y ).c_str(),
856 formatInternalUnits( aDimension->GetEnd().x ).c_str(),
857 formatInternalUnits( aDimension->GetEnd().y ).c_str() );
858
859 if( aligned )
860 {
861 m_out->Print( aNestLevel+1, "(height %s)\n",
862 formatInternalUnits( aligned->GetHeight() ).c_str() );
863 }
864
865 if( radial )
866 {
867 m_out->Print( aNestLevel+1, "(leader_length %s)\n",
868 formatInternalUnits( radial->GetLeaderLength() ).c_str() );
869 }
870
871 if( ortho )
872 {
873 m_out->Print( aNestLevel+1, "(orientation %d)\n",
874 static_cast<int>( ortho->GetOrientation() ) );
875 }
876
877 if( !center )
878 {
879 format( static_cast<const PCB_TEXT*>( aDimension ), aNestLevel + 1 );
880
881 m_out->Print( aNestLevel + 1, "(format (prefix %s) (suffix %s) (units %d) (units_format %d) (precision %d)",
882 m_out->Quotew( aDimension->GetPrefix() ).c_str(),
883 m_out->Quotew( aDimension->GetSuffix() ).c_str(),
884 static_cast<int>( aDimension->GetUnitsMode() ),
885 static_cast<int>( aDimension->GetUnitsFormat() ),
886 static_cast<int>( aDimension->GetPrecision() ) );
887
888 if( aDimension->GetOverrideTextEnabled() )
889 {
890 m_out->Print( 0, " (override_value %s)",
891 m_out->Quotew( aDimension->GetOverrideText() ).c_str() );
892 }
893
894 if( aDimension->GetSuppressZeroes() )
895 m_out->Print( 0, " suppress_zeroes" );
896
897 m_out->Print( 0, ")\n" );
898 }
899
900 m_out->Print( aNestLevel+1, "(style (thickness %s) (arrow_length %s) (text_position_mode %d)",
901 formatInternalUnits( aDimension->GetLineThickness() ).c_str(),
902 formatInternalUnits( aDimension->GetArrowLength() ).c_str(),
903 static_cast<int>( aDimension->GetTextPositionMode() ) );
904
905 if( aligned )
906 {
907 m_out->Print( 0, " (extension_height %s)",
908 formatInternalUnits( aligned->GetExtensionHeight() ).c_str() );
909 }
910
911 if( leader )
912 m_out->Print( 0, " (text_frame %d)", static_cast<int>( leader->GetTextBorder() ) );
913
914 m_out->Print( 0, " (extension_offset %s)",
915 formatInternalUnits( aDimension->GetExtensionOffset() ).c_str() );
916
917 if( aDimension->GetKeepTextAligned() )
918 m_out->Print( 0, " keep_text_aligned" );
919
920 m_out->Print( 0, ")\n" );
921
922 m_out->Print( aNestLevel, ")\n" );
923}
924
925
926void PCB_PLUGIN::format( const PCB_SHAPE* aShape, int aNestLevel ) const
927{
928 FOOTPRINT* parentFP = aShape->GetParentFootprint();
929 std::string prefix = parentFP ? "fp" : "gr";
930 std::string locked = aShape->IsLocked() ? " locked" : "";
931
932 switch( aShape->GetShape() )
933 {
934 case SHAPE_T::SEGMENT:
935 m_out->Print( aNestLevel, "(%s_line%s (start %s) (end %s)\n",
936 prefix.c_str(),
937 locked.c_str(),
938 formatInternalUnits( aShape->GetStart(), parentFP ).c_str(),
939 formatInternalUnits( aShape->GetEnd(), parentFP ).c_str() );
940 break;
941
942 case SHAPE_T::RECTANGLE:
943 m_out->Print( aNestLevel, "(%s_rect%s (start %s) (end %s)\n",
944 prefix.c_str(),
945 locked.c_str(),
946 formatInternalUnits( aShape->GetStart(), parentFP ).c_str(),
947 formatInternalUnits( aShape->GetEnd(), parentFP ).c_str() );
948 break;
949
950 case SHAPE_T::CIRCLE:
951 m_out->Print( aNestLevel, "(%s_circle%s (center %s) (end %s)\n",
952 prefix.c_str(),
953 locked.c_str(),
954 formatInternalUnits( aShape->GetStart(), parentFP ).c_str(),
955 formatInternalUnits( aShape->GetEnd(), parentFP ).c_str() );
956 break;
957
958 case SHAPE_T::ARC:
959 m_out->Print( aNestLevel, "(%s_arc%s (start %s) (mid %s) (end %s)\n",
960 prefix.c_str(),
961 locked.c_str(),
962 formatInternalUnits( aShape->GetStart(), parentFP ).c_str(),
963 formatInternalUnits( aShape->GetArcMid(), parentFP ).c_str(),
964 formatInternalUnits( aShape->GetEnd(), parentFP ).c_str() );
965 break;
966
967 case SHAPE_T::POLY:
968 if( aShape->IsPolyShapeValid() )
969 {
970 const SHAPE_POLY_SET& poly = aShape->GetPolyShape();
971 const SHAPE_LINE_CHAIN& outline = poly.Outline( 0 );
972
973 m_out->Print( aNestLevel, "(%s_poly%s\n",
974 prefix.c_str(),
975 locked.c_str() );
976 formatPolyPts( outline, aNestLevel, ADVANCED_CFG::GetCfg().m_CompactSave, parentFP );
977 }
978 else
979 {
980 wxFAIL_MSG( wxT( "Cannot format invalid polygon." ) );
981 return;
982 }
983
984 break;
985
986 case SHAPE_T::BEZIER:
987 m_out->Print( aNestLevel, "(%s_curve%s (pts (xy %s) (xy %s) (xy %s) (xy %s))\n",
988 prefix.c_str(),
989 locked.c_str(),
990 formatInternalUnits( aShape->GetStart(), parentFP ).c_str(),
991 formatInternalUnits( aShape->GetBezierC1(), parentFP ).c_str(),
992 formatInternalUnits( aShape->GetBezierC2(), parentFP ).c_str(),
993 formatInternalUnits( aShape->GetEnd(), parentFP ).c_str() );
994 break;
995
996 default:
998 return;
999 };
1000
1001 aShape->GetStroke().Format( m_out, pcbIUScale, aNestLevel + 1 );
1002
1003 // The filled flag represents if a solid fill is present on circles, rectangles and polygons
1004 if( ( aShape->GetShape() == SHAPE_T::POLY )
1005 || ( aShape->GetShape() == SHAPE_T::RECTANGLE )
1006 || ( aShape->GetShape() == SHAPE_T::CIRCLE ) )
1007 {
1008 m_out->Print( 0, aShape->IsFilled() ? " (fill solid)" : " (fill none)" );
1009 }
1010
1011 formatLayer( aShape->GetLayer() );
1012
1013 if( aShape->GetNetCode() > 0 )
1014 m_out->Print( 0, " (net %d)", m_mapping->Translate( aShape->GetNetCode() ) );
1015
1016 m_out->Print( 0, " (tstamp %s)", TO_UTF8( aShape->m_Uuid.AsString() ) );
1017
1018 m_out->Print( 0, ")\n" );
1019}
1020
1021
1022void PCB_PLUGIN::format( const PCB_BITMAP* aBitmap, int aNestLevel ) const
1023{
1024 wxCHECK_RET( aBitmap != nullptr && m_out != nullptr, "" );
1025
1026 const wxImage* image = aBitmap->GetImage()->GetImageData();
1027
1028 wxCHECK_RET( image != nullptr, "wxImage* is NULL" );
1029
1030 m_out->Print( aNestLevel, "(image (at %s %s)",
1031 formatInternalUnits( aBitmap->GetPosition().x ).c_str(),
1032 formatInternalUnits( aBitmap->GetPosition().y ).c_str() );
1033
1034 formatLayer( aBitmap->GetLayer() );
1035
1036 if( aBitmap->GetImage()->GetScale() != 1.0 )
1037 m_out->Print( 0, " (scale %g)", aBitmap->GetImage()->GetScale() );
1038
1039 m_out->Print( 0, "\n" );
1040
1041 m_out->Print( aNestLevel + 1, "(data" );
1042
1043 wxString out = wxBase64Encode( aBitmap->GetImage()->GetImageDataBuffer() );
1044
1045 // Apparently the MIME standard character width for base64 encoding is 76 (unconfirmed)
1046 // so use it in a vain attempt to be standard like.
1047#define MIME_BASE64_LENGTH 76
1048
1049 size_t first = 0;
1050
1051 while( first < out.Length() )
1052 {
1053 m_out->Print( 0, "\n" );
1054 m_out->Print( aNestLevel + 2, "%s", TO_UTF8( out( first, MIME_BASE64_LENGTH ) ) );
1055 first += MIME_BASE64_LENGTH;
1056 }
1057
1058 m_out->Print( 0, "\n" );
1059 m_out->Print( aNestLevel + 1, ")\n" ); // Closes data token.
1060 m_out->Print( aNestLevel, ")\n" ); // Closes image token.
1061}
1062
1063
1064void PCB_PLUGIN::format( const PCB_TARGET* aTarget, int aNestLevel ) const
1065{
1066 m_out->Print( aNestLevel, "(target %s (at %s) (size %s)",
1067 ( aTarget->GetShape() ) ? "x" : "plus",
1068 formatInternalUnits( aTarget->GetPosition() ).c_str(),
1069 formatInternalUnits( aTarget->GetSize() ).c_str() );
1070
1071 if( aTarget->GetWidth() != 0 )
1072 m_out->Print( 0, " (width %s)", formatInternalUnits( aTarget->GetWidth() ).c_str() );
1073
1074 formatLayer( aTarget->GetLayer() );
1075
1076 m_out->Print( 0, " (tstamp %s)", TO_UTF8( aTarget->m_Uuid.AsString() ) );
1077
1078 m_out->Print( 0, ")\n" );
1079}
1080
1081
1082void PCB_PLUGIN::format( const FOOTPRINT* aFootprint, int aNestLevel ) const
1083{
1084 if( !( m_ctl & CTL_OMIT_INITIAL_COMMENTS ) )
1085 {
1086 const wxArrayString* initial_comments = aFootprint->GetInitialComments();
1087
1088 if( initial_comments )
1089 {
1090 for( unsigned i = 0; i < initial_comments->GetCount(); ++i )
1091 m_out->Print( aNestLevel, "%s\n", TO_UTF8( (*initial_comments)[i] ) );
1092
1093 m_out->Print( 0, "\n" ); // improve readability?
1094 }
1095 }
1096
1097 if( m_ctl & CTL_OMIT_LIBNAME )
1098 {
1099 m_out->Print( aNestLevel, "(footprint %s",
1100 m_out->Quotes( aFootprint->GetFPID().GetLibItemName() ).c_str() );
1101 }
1102 else
1103 {
1104 m_out->Print( aNestLevel, "(footprint %s",
1105 m_out->Quotes( aFootprint->GetFPID().Format() ).c_str() );
1106 }
1107
1109 m_out->Print( 0, " (version %d) (generator pcbnew)\n ", SEXPR_BOARD_FILE_VERSION );
1110
1111 if( aFootprint->IsLocked() )
1112 m_out->Print( 0, " locked" );
1113
1114 if( aFootprint->IsPlaced() )
1115 m_out->Print( 0, " placed" );
1116
1117 formatLayer( aFootprint->GetLayer() );
1118
1119 m_out->Print( 0, "\n" );
1120
1121 if( !( m_ctl & CTL_OMIT_TSTAMPS ) )
1122 m_out->Print( aNestLevel+1, "(tstamp %s)\n", TO_UTF8( aFootprint->m_Uuid.AsString() ) );
1123
1124 if( !( m_ctl & CTL_OMIT_AT ) )
1125 {
1126 m_out->Print( aNestLevel+1, "(at %s", formatInternalUnits( aFootprint->GetPosition() ).c_str() );
1127
1128 if( !aFootprint->GetOrientation().IsZero() )
1129 m_out->Print( 0, " %s", EDA_UNIT_UTILS::FormatAngle( aFootprint->GetOrientation() ).c_str() );
1130
1131 m_out->Print( 0, ")\n" );
1132 }
1133
1134 if( !aFootprint->GetLibDescription().IsEmpty() )
1135 {
1136 m_out->Print( aNestLevel + 1, "(descr %s)\n",
1137 m_out->Quotew( aFootprint->GetLibDescription() ).c_str() );
1138 }
1139
1140 if( !aFootprint->GetKeywords().IsEmpty() )
1141 {
1142 m_out->Print( aNestLevel+1, "(tags %s)\n",
1143 m_out->Quotew( aFootprint->GetKeywords() ).c_str() );
1144 }
1145
1146 for( const PCB_FIELD* field : aFootprint->GetFields() )
1147 {
1148 m_out->Print( aNestLevel + 1, "(property %s %s",
1149 m_out->Quotew( field->GetCanonicalName() ).c_str(),
1150 m_out->Quotew( field->GetText() ).c_str() );
1151
1152 format( field, aNestLevel + 1 );
1153
1154 m_out->Print( aNestLevel + 1, ")\n" );
1155 }
1156
1157 if( !( m_ctl & CTL_OMIT_PATH ) && !aFootprint->GetPath().empty() )
1158 {
1159 m_out->Print( aNestLevel+1, "(path %s)\n",
1160 m_out->Quotew( aFootprint->GetPath().AsString() ).c_str() );
1161 }
1162
1163 if( !aFootprint->GetSheetname().empty() )
1164 {
1165 m_out->Print( aNestLevel + 1, "(sheetname %s)\n",
1166 m_out->Quotew( aFootprint->GetSheetname() ).c_str() );
1167 }
1168
1169 if( !aFootprint->GetSheetfile().empty() )
1170 {
1171 m_out->Print( aNestLevel + 1, "(sheetfile %s)\n",
1172 m_out->Quotew( aFootprint->GetSheetfile() ).c_str() );
1173 }
1174
1175 if( aFootprint->GetLocalSolderMaskMargin() != 0 )
1176 {
1177 m_out->Print( aNestLevel+1, "(solder_mask_margin %s)\n",
1178 formatInternalUnits( aFootprint->GetLocalSolderMaskMargin() ).c_str() );
1179 }
1180
1181 if( aFootprint->GetLocalSolderPasteMargin() != 0 )
1182 {
1183 m_out->Print( aNestLevel+1, "(solder_paste_margin %s)\n",
1184 formatInternalUnits( aFootprint->GetLocalSolderPasteMargin() ).c_str() );
1185 }
1186
1187 if( aFootprint->GetLocalSolderPasteMarginRatio() != 0 )
1188 {
1189 m_out->Print( aNestLevel+1, "(solder_paste_ratio %s)\n",
1190 FormatDouble2Str( aFootprint->GetLocalSolderPasteMarginRatio() ).c_str() );
1191 }
1192
1193 if( aFootprint->GetLocalClearance() != 0 )
1194 {
1195 m_out->Print( aNestLevel+1, "(clearance %s)\n",
1196 formatInternalUnits( aFootprint->GetLocalClearance() ).c_str() );
1197 }
1198
1199 if( aFootprint->GetZoneConnection() != ZONE_CONNECTION::INHERITED )
1200 {
1201 m_out->Print( aNestLevel+1, "(zone_connect %d)\n",
1202 static_cast<int>( aFootprint->GetZoneConnection() ) );
1203 }
1204
1205 // Attributes
1206 if( aFootprint->GetAttributes() )
1207 {
1208 m_out->Print( aNestLevel+1, "(attr" );
1209
1210 if( aFootprint->GetAttributes() & FP_SMD )
1211 m_out->Print( 0, " smd" );
1212
1213 if( aFootprint->GetAttributes() & FP_THROUGH_HOLE )
1214 m_out->Print( 0, " through_hole" );
1215
1216 if( aFootprint->GetAttributes() & FP_BOARD_ONLY )
1217 m_out->Print( 0, " board_only" );
1218
1219 if( aFootprint->GetAttributes() & FP_EXCLUDE_FROM_POS_FILES )
1220 m_out->Print( 0, " exclude_from_pos_files" );
1221
1222 if( aFootprint->GetAttributes() & FP_EXCLUDE_FROM_BOM )
1223 m_out->Print( 0, " exclude_from_bom" );
1224
1225 if( aFootprint->GetAttributes() & FP_ALLOW_MISSING_COURTYARD )
1226 m_out->Print( 0, " allow_missing_courtyard" );
1227
1228 if( aFootprint->GetAttributes() & FP_DNP )
1229 m_out->Print( 0, " dnp" );
1230
1231 if( aFootprint->GetAttributes() & FP_ALLOW_SOLDERMASK_BRIDGES )
1232 m_out->Print( 0, " allow_soldermask_bridges" );
1233
1234 m_out->Print( 0, ")\n" );
1235 }
1236
1237 if( aFootprint->GetPrivateLayers().any() )
1238 {
1239 m_out->Print( aNestLevel+1, "(private_layers" );
1240
1241 for( PCB_LAYER_ID layer : aFootprint->GetPrivateLayers().Seq() )
1242 {
1243 wxString canonicalName( LSET::Name( layer ) );
1244 m_out->Print( 0, " \"%s\"", canonicalName.ToStdString().c_str() );
1245 }
1246
1247 m_out->Print( 0, ")\n" );
1248 }
1249
1250 if( aFootprint->IsNetTie() )
1251 {
1252 m_out->Print( aNestLevel+1, "(net_tie_pad_groups" );
1253
1254 for( const wxString& group : aFootprint->GetNetTiePadGroups() )
1255 m_out->Print( 0, " \"%s\"", EscapeString( group, CTX_QUOTED_STR ).ToStdString().c_str() );
1256
1257 m_out->Print( 0, ")\n" );
1258 }
1259
1260 Format( (BOARD_ITEM*) &aFootprint->Reference(), aNestLevel + 1 );
1261 Format( (BOARD_ITEM*) &aFootprint->Value(), aNestLevel + 1 );
1262
1263 std::set<PAD*, FOOTPRINT::cmp_pads> sorted_pads( aFootprint->Pads().begin(),
1264 aFootprint->Pads().end() );
1265 std::set<BOARD_ITEM*, FOOTPRINT::cmp_drawings> sorted_drawings(
1266 aFootprint->GraphicalItems().begin(),
1267 aFootprint->GraphicalItems().end() );
1268 std::set<ZONE*, FOOTPRINT::cmp_zones> sorted_zones( aFootprint->Zones().begin(),
1269 aFootprint->Zones().end() );
1270 std::set<BOARD_ITEM*, PCB_GROUP::ptr_cmp> sorted_groups( aFootprint->Groups().begin(),
1271 aFootprint->Groups().end() );
1272
1273 // Save drawing elements.
1274
1275 for( BOARD_ITEM* gr : sorted_drawings )
1276 Format( gr, aNestLevel+1 );
1277
1278 // Save pads.
1279 for( PAD* pad : sorted_pads )
1280 Format( pad, aNestLevel+1 );
1281
1282 // Save zones.
1283 for( BOARD_ITEM* zone : sorted_zones )
1284 Format( zone, aNestLevel + 1 );
1285
1286 // Save groups.
1287 for( BOARD_ITEM* group : sorted_groups )
1288 Format( group, aNestLevel + 1 );
1289
1290 // Save 3D info.
1291 auto bs3D = aFootprint->Models().begin();
1292 auto es3D = aFootprint->Models().end();
1293
1294 while( bs3D != es3D )
1295 {
1296 if( !bs3D->m_Filename.IsEmpty() )
1297 {
1298 m_out->Print( aNestLevel+1, "(model %s%s\n",
1299 m_out->Quotew( bs3D->m_Filename ).c_str(),
1300 bs3D->m_Show ? "" : " hide" );
1301
1302 if( bs3D->m_Opacity != 1.0 )
1303 m_out->Print( aNestLevel+2, "(opacity %0.4f)", bs3D->m_Opacity );
1304
1305 m_out->Print( aNestLevel+2, "(offset (xyz %s %s %s))\n",
1306 FormatDouble2Str( bs3D->m_Offset.x ).c_str(),
1307 FormatDouble2Str( bs3D->m_Offset.y ).c_str(),
1308 FormatDouble2Str( bs3D->m_Offset.z ).c_str() );
1309
1310 m_out->Print( aNestLevel+2, "(scale (xyz %s %s %s))\n",
1311 FormatDouble2Str( bs3D->m_Scale.x ).c_str(),
1312 FormatDouble2Str( bs3D->m_Scale.y ).c_str(),
1313 FormatDouble2Str( bs3D->m_Scale.z ).c_str() );
1314
1315 m_out->Print( aNestLevel+2, "(rotate (xyz %s %s %s))\n",
1316 FormatDouble2Str( bs3D->m_Rotation.x ).c_str(),
1317 FormatDouble2Str( bs3D->m_Rotation.y ).c_str(),
1318 FormatDouble2Str( bs3D->m_Rotation.z ).c_str() );
1319
1320 m_out->Print( aNestLevel+1, ")\n" );
1321 }
1322
1323 ++bs3D;
1324 }
1325
1326 m_out->Print( aNestLevel, ")\n" );
1327}
1328
1329
1330void PCB_PLUGIN::formatLayers( LSET aLayerMask, int aNestLevel ) const
1331{
1332 std::string output;
1333
1334 if( aNestLevel == 0 )
1335 output += ' ';
1336
1337 output += "(layers";
1338
1339 static const LSET cu_all( LSET::AllCuMask() );
1340 static const LSET fr_bk( 2, B_Cu, F_Cu );
1341 static const LSET adhes( 2, B_Adhes, F_Adhes );
1342 static const LSET paste( 2, B_Paste, F_Paste );
1343 static const LSET silks( 2, B_SilkS, F_SilkS );
1344 static const LSET mask( 2, B_Mask, F_Mask );
1345 static const LSET crt_yd( 2, B_CrtYd, F_CrtYd );
1346 static const LSET fab( 2, B_Fab, F_Fab );
1347
1348 LSET cu_mask = cu_all;
1349
1350 // output copper layers first, then non copper
1351
1352 if( ( aLayerMask & cu_mask ) == cu_mask )
1353 {
1354 output += ' ' + m_out->Quotew( "*.Cu" );
1355 aLayerMask &= ~cu_all; // clear bits, so they are not output again below
1356 }
1357 else if( ( aLayerMask & cu_mask ) == fr_bk )
1358 {
1359 output += ' ' + m_out->Quotew( "F&B.Cu" );
1360 aLayerMask &= ~fr_bk;
1361 }
1362
1363 if( ( aLayerMask & adhes ) == adhes )
1364 {
1365 output += ' ' + m_out->Quotew( "*.Adhes" );
1366 aLayerMask &= ~adhes;
1367 }
1368
1369 if( ( aLayerMask & paste ) == paste )
1370 {
1371 output += ' ' + m_out->Quotew( "*.Paste" );
1372 aLayerMask &= ~paste;
1373 }
1374
1375 if( ( aLayerMask & silks ) == silks )
1376 {
1377 output += ' ' + m_out->Quotew( "*.SilkS" );
1378 aLayerMask &= ~silks;
1379 }
1380
1381 if( ( aLayerMask & mask ) == mask )
1382 {
1383 output += ' ' + m_out->Quotew( "*.Mask" );
1384 aLayerMask &= ~mask;
1385 }
1386
1387 if( ( aLayerMask & crt_yd ) == crt_yd )
1388 {
1389 output += ' ' + m_out->Quotew( "*.CrtYd" );
1390 aLayerMask &= ~crt_yd;
1391 }
1392
1393 if( ( aLayerMask & fab ) == fab )
1394 {
1395 output += ' ' + m_out->Quotew( "*.Fab" );
1396 aLayerMask &= ~fab;
1397 }
1398
1399 // output any individual layers not handled in wildcard combos above
1400 wxString layerName;
1401
1402 for( int layer = 0; layer < PCB_LAYER_ID_COUNT; ++layer )
1403 {
1404 if( aLayerMask[layer] )
1405 {
1406 layerName = LSET::Name( PCB_LAYER_ID( layer ) );
1407 output += ' ';
1408 output += m_out->Quotew( layerName );
1409 }
1410 }
1411
1412 m_out->Print( aNestLevel, "%s)", output.c_str() );
1413}
1414
1415
1416void PCB_PLUGIN::format( const PAD* aPad, int aNestLevel ) const
1417{
1418 const BOARD* board = aPad->GetBoard();
1419 const char* shape;
1420
1421 switch( aPad->GetShape() )
1422 {
1423 case PAD_SHAPE::CIRCLE: shape = "circle"; break;
1424 case PAD_SHAPE::RECTANGLE: shape = "rect"; break;
1425 case PAD_SHAPE::OVAL: shape = "oval"; break;
1426 case PAD_SHAPE::TRAPEZOID: shape = "trapezoid"; break;
1427 case PAD_SHAPE::CHAMFERED_RECT:
1428 case PAD_SHAPE::ROUNDRECT: shape = "roundrect"; break;
1429 case PAD_SHAPE::CUSTOM: shape = "custom"; break;
1430
1431 default:
1432 THROW_IO_ERROR( wxString::Format( _( "unknown pad type: %d"), aPad->GetShape() ) );
1433 }
1434
1435 const char* type;
1436
1437 switch( aPad->GetAttribute() )
1438 {
1439 case PAD_ATTRIB::PTH: type = "thru_hole"; break;
1440 case PAD_ATTRIB::SMD: type = "smd"; break;
1441 case PAD_ATTRIB::CONN: type = "connect"; break;
1442 case PAD_ATTRIB::NPTH: type = "np_thru_hole"; break;
1443
1444 default:
1445 THROW_IO_ERROR( wxString::Format( wxT( "unknown pad attribute: %d" ),
1446 aPad->GetAttribute() ) );
1447 }
1448
1449 const char* property = nullptr;
1450
1451 switch( aPad->GetProperty() )
1452 {
1453 case PAD_PROP::NONE: break; // could be "none"
1454 case PAD_PROP::BGA: property = "pad_prop_bga"; break;
1455 case PAD_PROP::FIDUCIAL_GLBL: property = "pad_prop_fiducial_glob"; break;
1456 case PAD_PROP::FIDUCIAL_LOCAL: property = "pad_prop_fiducial_loc"; break;
1457 case PAD_PROP::TESTPOINT: property = "pad_prop_testpoint"; break;
1458 case PAD_PROP::HEATSINK: property = "pad_prop_heatsink"; break;
1459 case PAD_PROP::CASTELLATED: property = "pad_prop_castellated"; break;
1460
1461 default:
1462 THROW_IO_ERROR( wxString::Format( wxT( "unknown pad property: %d" ),
1463 aPad->GetProperty() ) );
1464 }
1465
1466 m_out->Print( aNestLevel, "(pad %s %s %s",
1467 m_out->Quotew( aPad->GetNumber() ).c_str(),
1468 type,
1469 shape );
1470
1471 if( aPad->IsLocked() )
1472 m_out->Print( 0, " locked" );
1473
1474 m_out->Print( 0, " (at %s", formatInternalUnits( aPad->GetFPRelativePosition() ).c_str() );
1475
1476 if( !aPad->GetOrientation().IsZero() )
1477 m_out->Print( 0, " %s", EDA_UNIT_UTILS::FormatAngle( aPad->GetOrientation() ).c_str() );
1478
1479 m_out->Print( 0, ")" );
1480
1481 m_out->Print( 0, " (size %s)", formatInternalUnits( aPad->GetSize() ).c_str() );
1482
1483 if( (aPad->GetDelta().x) != 0 || (aPad->GetDelta().y != 0 ) )
1484 m_out->Print( 0, " (rect_delta %s)", formatInternalUnits( aPad->GetDelta() ).c_str() );
1485
1486 VECTOR2I sz = aPad->GetDrillSize();
1487 VECTOR2I shapeoffset = aPad->GetOffset();
1488
1489 if( (sz.x > 0) || (sz.y > 0) ||
1490 (shapeoffset.x != 0) || (shapeoffset.y != 0) )
1491 {
1492 m_out->Print( 0, " (drill" );
1493
1494 if( aPad->GetDrillShape() == PAD_DRILL_SHAPE_OBLONG )
1495 m_out->Print( 0, " oval" );
1496
1497 if( sz.x > 0 )
1498 m_out->Print( 0, " %s", formatInternalUnits( sz.x ).c_str() );
1499
1500 if( sz.y > 0 && sz.x != sz.y )
1501 m_out->Print( 0, " %s", formatInternalUnits( sz.y ).c_str() );
1502
1503 if( (shapeoffset.x != 0) || (shapeoffset.y != 0) )
1504 m_out->Print( 0, " (offset %s)", formatInternalUnits( aPad->GetOffset() ).c_str() );
1505
1506 m_out->Print( 0, ")" );
1507 }
1508
1509 // Add pad property, if exists.
1510 if( property )
1511 m_out->Print( 0, " (property %s)", property );
1512
1513 formatLayers( aPad->GetLayerSet() );
1514
1515 if( aPad->GetAttribute() == PAD_ATTRIB::PTH )
1516 {
1517 if( aPad->GetRemoveUnconnected() )
1518 {
1519 m_out->Print( 0, " (remove_unused_layers)" );
1520
1521 if( aPad->GetKeepTopBottom() )
1522 m_out->Print( 0, " (keep_end_layers)" );
1523
1524 if( board ) // Will be nullptr in footprint library
1525 {
1526 m_out->Print( 0, " (zone_layer_connections" );
1527
1528 for( LSEQ cu = board->GetEnabledLayers().CuStack(); cu; ++cu )
1529 {
1530 if( aPad->GetZoneLayerOverride( *cu ) == ZLO_FORCE_FLASHED )
1531 m_out->Print( 0, " %s", m_out->Quotew( LSET::Name( *cu ) ).c_str() );
1532 }
1533
1534 m_out->Print( 0, ")" );
1535 }
1536 }
1537 }
1538
1539 // Output the radius ratio for rounded and chamfered rect pads
1540 if( aPad->GetShape() == PAD_SHAPE::ROUNDRECT || aPad->GetShape() == PAD_SHAPE::CHAMFERED_RECT)
1541 {
1542 m_out->Print( 0, " (roundrect_rratio %s)",
1543 FormatDouble2Str( aPad->GetRoundRectRadiusRatio() ).c_str() );
1544 }
1545
1546 // Output the chamfer corners for chamfered rect pads
1547 if( aPad->GetShape() == PAD_SHAPE::CHAMFERED_RECT)
1548 {
1549 m_out->Print( 0, "\n" );
1550
1551 m_out->Print( aNestLevel+1, "(chamfer_ratio %s)",
1552 FormatDouble2Str( aPad->GetChamferRectRatio() ).c_str() );
1553
1554 m_out->Print( 0, " (chamfer" );
1555
1556 if( ( aPad->GetChamferPositions() & RECT_CHAMFER_TOP_LEFT ) )
1557 m_out->Print( 0, " top_left" );
1558
1560 m_out->Print( 0, " top_right" );
1561
1563 m_out->Print( 0, " bottom_left" );
1564
1566 m_out->Print( 0, " bottom_right" );
1567
1568 m_out->Print( 0, ")" );
1569 }
1570
1571 std::string output;
1572
1573 // Unconnected pad is default net so don't save it.
1575 {
1576 StrPrintf( &output, " (net %d %s)", m_mapping->Translate( aPad->GetNetCode() ),
1577 m_out->Quotew( aPad->GetNetname() ).c_str() );
1578 }
1579
1580 // Pin functions and types are closely related to nets, so if CTL_OMIT_NETS is set, omit
1581 // them as well (for instance when saved from library editor).
1582 if( !( m_ctl & CTL_OMIT_PAD_NETS ) )
1583 {
1584 if( !aPad->GetPinFunction().IsEmpty() )
1585 {
1586 StrPrintf( &output, " (pinfunction %s)",
1587 m_out->Quotew( aPad->GetPinFunction() ).c_str() );
1588 }
1589
1590 if( !aPad->GetPinType().IsEmpty() )
1591 {
1592 StrPrintf( &output, " (pintype %s)",
1593 m_out->Quotew( aPad->GetPinType() ).c_str() );
1594 }
1595 }
1596
1597 if( aPad->GetPadToDieLength() != 0 )
1598 {
1599 StrPrintf( &output, " (die_length %s)",
1600 formatInternalUnits( aPad->GetPadToDieLength() ).c_str() );
1601 }
1602
1603 if( aPad->GetLocalSolderMaskMargin() != 0 )
1604 {
1605 StrPrintf( &output, " (solder_mask_margin %s)",
1606 formatInternalUnits( aPad->GetLocalSolderMaskMargin() ).c_str() );
1607 }
1608
1609 if( aPad->GetLocalSolderPasteMargin() != 0 )
1610 {
1611 StrPrintf( &output, " (solder_paste_margin %s)",
1613 }
1614
1615 if( aPad->GetLocalSolderPasteMarginRatio() != 0 )
1616 {
1617 StrPrintf( &output, " (solder_paste_margin_ratio %s)",
1619 }
1620
1621 if( aPad->GetLocalClearance() != 0 )
1622 {
1623 StrPrintf( &output, " (clearance %s)",
1624 formatInternalUnits( aPad->GetLocalClearance() ).c_str() );
1625 }
1626
1627 if( aPad->GetZoneConnection() != ZONE_CONNECTION::INHERITED )
1628 {
1629 StrPrintf( &output, " (zone_connect %d)",
1630 static_cast<int>( aPad->GetZoneConnection() ) );
1631 }
1632
1633 if( aPad->GetThermalSpokeWidth() != 0 )
1634 {
1635 StrPrintf( &output, " (thermal_bridge_width %s)",
1636 formatInternalUnits( aPad->GetThermalSpokeWidth() ).c_str() );
1637 }
1638
1639 EDA_ANGLE defaultThermalSpokeAngle = ANGLE_90;
1640
1641 if( aPad->GetShape() == PAD_SHAPE::CIRCLE ||
1642 ( aPad->GetShape() == PAD_SHAPE::CUSTOM && aPad->GetAnchorPadShape() == PAD_SHAPE::CIRCLE ) )
1643 {
1644 defaultThermalSpokeAngle = ANGLE_45;
1645 }
1646
1647 if( aPad->GetThermalSpokeAngle() != defaultThermalSpokeAngle )
1648 {
1649 StrPrintf( &output, " (thermal_bridge_angle %s)",
1651 }
1652
1653 if( aPad->GetThermalGap() != 0 )
1654 {
1655 StrPrintf( &output, " (thermal_gap %s)",
1656 formatInternalUnits( aPad->GetThermalGap() ).c_str() );
1657 }
1658
1659 if( output.size() )
1660 {
1661 m_out->Print( 0, "\n" );
1662 m_out->Print( aNestLevel+1, "%s", output.c_str()+1 ); // +1 skips 1st space on 1st element
1663 }
1664
1665 if( aPad->GetShape() == PAD_SHAPE::CUSTOM )
1666 {
1667 m_out->Print( 0, "\n");
1668 m_out->Print( aNestLevel+1, "(options" );
1669
1671 m_out->Print( 0, " (clearance convexhull)" );
1672 #if 1 // Set to 1 to output the default option
1673 else
1674 m_out->Print( 0, " (clearance outline)" );
1675 #endif
1676
1677 // Output the anchor pad shape (circle/rect)
1678 if( aPad->GetAnchorPadShape() == PAD_SHAPE::RECTANGLE )
1679 shape = "rect";
1680 else
1681 shape = "circle";
1682
1683 m_out->Print( 0, " (anchor %s)", shape );
1684
1685 m_out->Print( 0, ")"); // end of (options ...
1686
1687 // Output graphic primitive of the pad shape
1688 m_out->Print( 0, "\n");
1689 m_out->Print( aNestLevel+1, "(primitives" );
1690
1691 int nested_level = aNestLevel+2;
1692
1693 // Output all basic shapes
1694 for( const std::shared_ptr<PCB_SHAPE>& primitive : aPad->GetPrimitives() )
1695 {
1696 m_out->Print( 0, "\n");
1697
1698 switch( primitive->GetShape() )
1699 {
1700 case SHAPE_T::SEGMENT:
1701 if( primitive->IsProxyItem() )
1702 {
1703 m_out->Print( nested_level, "(gr_vector (start %s) (end %s)",
1704 formatInternalUnits( primitive->GetStart() ).c_str(),
1705 formatInternalUnits( primitive->GetEnd() ).c_str() );
1706 }
1707 else
1708 {
1709 m_out->Print( nested_level, "(gr_line (start %s) (end %s)",
1710 formatInternalUnits( primitive->GetStart() ).c_str(),
1711 formatInternalUnits( primitive->GetEnd() ).c_str() );
1712 }
1713 break;
1714
1715 case SHAPE_T::RECTANGLE:
1716 if( primitive->IsProxyItem() )
1717 {
1718 m_out->Print( nested_level, "(gr_bbox (start %s) (end %s)",
1719 formatInternalUnits( primitive->GetStart() ).c_str(),
1720 formatInternalUnits( primitive->GetEnd() ).c_str() );
1721 }
1722 else
1723 {
1724 m_out->Print( nested_level, "(gr_rect (start %s) (end %s)",
1725 formatInternalUnits( primitive->GetStart() ).c_str(),
1726 formatInternalUnits( primitive->GetEnd() ).c_str() );
1727 }
1728 break;
1729
1730 case SHAPE_T::ARC:
1731 m_out->Print( nested_level, "(gr_arc (start %s) (mid %s) (end %s)",
1732 formatInternalUnits( primitive->GetStart() ).c_str(),
1733 formatInternalUnits( primitive->GetArcMid() ).c_str(),
1734 formatInternalUnits( primitive->GetEnd() ).c_str() );
1735 break;
1736
1737 case SHAPE_T::CIRCLE:
1738 m_out->Print( nested_level, "(gr_circle (center %s) (end %s)",
1739 formatInternalUnits( primitive->GetStart() ).c_str(),
1740 formatInternalUnits( primitive->GetEnd() ).c_str() );
1741 break;
1742
1743 case SHAPE_T::BEZIER:
1744 m_out->Print( nested_level, "(gr_curve (pts (xy %s) (xy %s) (xy %s) (xy %s))",
1745 formatInternalUnits( primitive->GetStart() ).c_str(),
1746 formatInternalUnits( primitive->GetBezierC1() ).c_str(),
1747 formatInternalUnits( primitive->GetBezierC2() ).c_str(),
1748 formatInternalUnits( primitive->GetEnd() ).c_str() );
1749 break;
1750
1751 case SHAPE_T::POLY:
1752 if( primitive->IsPolyShapeValid() )
1753 {
1754 const SHAPE_POLY_SET& poly = primitive->GetPolyShape();
1755 const SHAPE_LINE_CHAIN& outline = poly.Outline( 0 );
1756
1757 m_out->Print( nested_level, "(gr_poly\n" );
1758 formatPolyPts( outline, nested_level, ADVANCED_CFG::GetCfg().m_CompactSave );
1759
1760 // Align the next info at the right place.
1761 m_out->Print( nested_level, " " );
1762 }
1763 break;
1764
1765 default:
1766 break;
1767 }
1768
1769 if( !primitive->IsProxyItem() )
1770 m_out->Print( 0, " (width %s)", formatInternalUnits( primitive->GetWidth() ).c_str() );
1771
1772 // The filled flag represents if a solid fill is present on circles,
1773 // rectangles and polygons
1774 if( ( primitive->GetShape() == SHAPE_T::POLY )
1775 || ( primitive->GetShape() == SHAPE_T::RECTANGLE )
1776 || ( primitive->GetShape() == SHAPE_T::CIRCLE ) )
1777 {
1778 m_out->Print( 0, primitive->IsFilled() ? " (fill yes)" : " (fill none)" );
1779 }
1780
1781 m_out->Print( 0, ")" );
1782 }
1783
1784 m_out->Print( 0, "\n" );
1785 m_out->Print( aNestLevel+1, ")" ); // end of (primitives
1786 }
1787
1789 {
1790 m_out->Print( 0, "\n" );
1791 formatTeardropParameters( aPad->GetTeardropParams(), aNestLevel+1 );
1792 }
1793
1794 m_out->Print( 0, "\n" );
1795 m_out->Print( aNestLevel + 1, "(tstamp %s)", TO_UTF8( aPad->m_Uuid.AsString() ) );
1796 m_out->Print( 0, "\n" );
1797 m_out->Print( aNestLevel, ")\n" );
1798}
1799
1800
1801void PCB_PLUGIN::format( const PCB_TEXT* aText, int aNestLevel ) const
1802{
1803 FOOTPRINT* parentFP = aText->GetParentFootprint();
1804 std::string prefix;
1805 std::string type;
1806 VECTOR2I pos = aText->GetTextPos();
1807 bool isField = dynamic_cast<const PCB_FIELD*>( aText ) != nullptr;
1808
1809 // Always format dimension text as gr_text
1810 if( dynamic_cast<const PCB_DIMENSION_BASE*>( aText ) )
1811 parentFP = nullptr;
1812
1813 if( parentFP )
1814 {
1815 prefix = "fp";
1816 type = " user";
1817
1818 pos -= parentFP->GetPosition();
1819 RotatePoint( pos, -parentFP->GetOrientation() );
1820 }
1821 else
1822 {
1823 prefix = "gr";
1824 }
1825
1826 if( !isField )
1827 {
1828 m_out->Print( aNestLevel, "(%s_text%s%s %s", prefix.c_str(), type.c_str(),
1829 aText->IsLocked() ? " locked" : "",
1830 m_out->Quotew( aText->GetText() ).c_str() );
1831 }
1832
1833 m_out->Print( 0, " (at %s", formatInternalUnits( pos ).c_str() );
1834
1835 // Due to Pcbnew history, fp_text angle is saved as an absolute on screen angle.
1836 // To avoid issues in the future, always save the angle, even if it is 0
1837 m_out->Print( 0, " %s", EDA_UNIT_UTILS::FormatAngle( aText->GetTextAngle() ).c_str() );
1838
1839 if( parentFP && !aText->IsKeepUpright() )
1840 m_out->Print( 0, " unlocked" );
1841
1842 m_out->Print( 0, ")" );
1843
1844 formatLayer( aText->GetLayer(), aText->IsKnockout() );
1845
1846 if( parentFP && !aText->IsVisible() )
1847 m_out->Print( 0, " hide" );
1848
1849 m_out->Print( 0, " (tstamp %s)", TO_UTF8( aText->m_Uuid.AsString() ) );
1850
1851 m_out->Print( 0, "\n" );
1852
1853 aText->EDA_TEXT::Format( m_out, aNestLevel, m_ctl | CTL_OMIT_HIDE );
1854
1855 if( aText->GetFont() && aText->GetFont()->IsOutline() )
1856 formatRenderCache( aText, aNestLevel + 1 );
1857
1858 if( !isField )
1859 m_out->Print( aNestLevel, ")\n" );
1860}
1861
1862
1863void PCB_PLUGIN::format( const PCB_TEXTBOX* aTextBox, int aNestLevel ) const
1864{
1865 FOOTPRINT* parentFP = aTextBox->GetParentFootprint();
1866
1867 m_out->Print( aNestLevel, "(%s%s %s\n",
1868 parentFP ? "fp_text_box" : "gr_text_box",
1869 aTextBox->IsLocked() ? " locked" : "",
1870 m_out->Quotew( aTextBox->GetText() ).c_str() );
1871
1872 if( aTextBox->GetShape() == SHAPE_T::RECTANGLE )
1873 {
1874 m_out->Print( aNestLevel + 1, "(start %s) (end %s)",
1875 formatInternalUnits( aTextBox->GetStart(), parentFP ).c_str(),
1876 formatInternalUnits( aTextBox->GetEnd(), parentFP ).c_str() );
1877 }
1878 else if( aTextBox->GetShape() == SHAPE_T::POLY )
1879 {
1880 const SHAPE_POLY_SET& poly = aTextBox->GetPolyShape();
1881 const SHAPE_LINE_CHAIN& outline = poly.Outline( 0 );
1882
1883 formatPolyPts( outline, aNestLevel, true, parentFP );
1884 }
1885 else
1886 {
1887 UNIMPLEMENTED_FOR( aTextBox->SHAPE_T_asString() );
1888 }
1889
1890 EDA_ANGLE angle = aTextBox->GetTextAngle();
1891
1892 if( parentFP )
1893 {
1894 angle -= parentFP->GetOrientation();
1895 angle.Normalize720();
1896 }
1897
1898 if( !angle.IsZero() )
1899 m_out->Print( aNestLevel + 1, "(angle %s)", EDA_UNIT_UTILS::FormatAngle( angle ).c_str() );
1900
1901 formatLayer( aTextBox->GetLayer() );
1902 m_out->Print( 0, "\n" );
1903
1904 m_out->Print( aNestLevel + 1, "(tstamp %s)", TO_UTF8( aTextBox->m_Uuid.AsString() ) );
1905
1906 m_out->Print( 0, "\n" );
1907
1908 // PCB_TEXTBOXes are never hidden, so always omit "hide" attribute
1909 aTextBox->EDA_TEXT::Format( m_out, aNestLevel, m_ctl | CTL_OMIT_HIDE );
1910
1911 m_out->Print( aNestLevel + 1, "(border" );
1912
1913 if( aTextBox->IsBorderEnabled() )
1914 m_out->Print( 0, " yes)" );
1915 else
1916 m_out->Print( 0, " no)" );
1917
1918 aTextBox->GetStroke().Format( m_out, pcbIUScale, aNestLevel + 1 );
1919
1920 if( aTextBox->GetFont() && aTextBox->GetFont()->IsOutline() )
1921 formatRenderCache( aTextBox, aNestLevel + 1 );
1922
1923 m_out->Print( aNestLevel, ")\n" );
1924}
1925
1926
1927void PCB_PLUGIN::format( const PCB_GROUP* aGroup, int aNestLevel ) const
1928{
1929 // Don't write empty groups
1930 if( aGroup->GetItems().empty() )
1931 return;
1932
1933 m_out->Print( aNestLevel, "(group %s%s (id %s)\n",
1934 m_out->Quotew( aGroup->GetName() ).c_str(),
1935 aGroup->IsLocked() ? " locked" : "",
1936 TO_UTF8( aGroup->m_Uuid.AsString() ) );
1937
1938 m_out->Print( aNestLevel + 1, "(members\n" );
1939
1940 wxArrayString memberIds;
1941
1942 for( BOARD_ITEM* member : aGroup->GetItems() )
1943 memberIds.Add( member->m_Uuid.AsString() );
1944
1945 memberIds.Sort();
1946
1947 for( const wxString& memberId : memberIds )
1948 m_out->Print( aNestLevel + 2, "%s\n", TO_UTF8( memberId ) );
1949
1950 m_out->Print( aNestLevel + 1, ")\n" ); // Close `members` token.
1951 m_out->Print( aNestLevel, ")\n" ); // Close `group` token.
1952}
1953
1954
1955void PCB_PLUGIN::format( const PCB_TRACK* aTrack, int aNestLevel ) const
1956{
1957 if( aTrack->Type() == PCB_VIA_T )
1958 {
1959 PCB_LAYER_ID layer1, layer2;
1960
1961 const PCB_VIA* via = static_cast<const PCB_VIA*>( aTrack );
1962 const BOARD* board = via->GetBoard();
1963
1964 wxCHECK_RET( board != nullptr, wxT( "Via has no parent." ) );
1965
1966 m_out->Print( aNestLevel, "(via" );
1967
1968 via->LayerPair( &layer1, &layer2 );
1969
1970 switch( via->GetViaType() )
1971 {
1972 case VIATYPE::THROUGH: // Default shape not saved.
1973 break;
1974
1975 case VIATYPE::BLIND_BURIED:
1976 m_out->Print( 0, " blind" );
1977 break;
1978
1979 case VIATYPE::MICROVIA:
1980 m_out->Print( 0, " micro" );
1981 break;
1982
1983 default:
1984 THROW_IO_ERROR( wxString::Format( _( "unknown via type %d" ), via->GetViaType() ) );
1985 }
1986
1987 if( via->IsLocked() )
1988 m_out->Print( 0, " locked" );
1989
1990 m_out->Print( 0, " (at %s) (size %s)",
1991 formatInternalUnits( aTrack->GetStart() ).c_str(),
1992 formatInternalUnits( aTrack->GetWidth() ).c_str() );
1993
1994 // Old boards were using UNDEFINED_DRILL_DIAMETER value in file for via drill when
1995 // via drill was the netclass value.
1996 // recent boards always set the via drill to the actual value, but now we need to
1997 // always store the drill value, because netclass value is not stored in the board file.
1998 // Otherwise the drill value of some (old) vias can be unknown
1999 if( via->GetDrill() != UNDEFINED_DRILL_DIAMETER )
2000 m_out->Print( 0, " (drill %s)", formatInternalUnits( via->GetDrill() ).c_str() );
2001 else
2002 m_out->Print( 0, " (drill %s)", formatInternalUnits( via->GetDrillValue() ).c_str() );
2003
2004 m_out->Print( 0, " (layers %s %s)",
2005 m_out->Quotew( LSET::Name( layer1 ) ).c_str(),
2006 m_out->Quotew( LSET::Name( layer2 ) ).c_str() );
2007
2008 if( via->GetRemoveUnconnected() )
2009 {
2010 m_out->Print( 0, " (remove_unused_layers)" );
2011
2012 if( via->GetKeepStartEnd() )
2013 m_out->Print( 0, " (keep_end_layers)" );
2014 }
2015
2016 if( via->GetIsFree() )
2017 m_out->Print( 0, " (free)" );
2018
2019 if( via->GetRemoveUnconnected() )
2020 {
2021 m_out->Print( 0, " (zone_layer_connections" );
2022
2023 for( LSEQ cu = board->GetEnabledLayers().CuStack(); cu; ++cu )
2024 {
2025 if( via->GetZoneLayerOverride( *cu ) == ZLO_FORCE_FLASHED )
2026 m_out->Print( 0, " %s", m_out->Quotew( LSET::Name( *cu ) ).c_str() );
2027 }
2028
2029 m_out->Print( 0, ")" );
2030 }
2031
2032 if( !isDefaultTeardropParameters( via->GetTeardropParams() ) )
2033 {
2034 m_out->Print( 0, "\n" );
2035 formatTeardropParameters( via->GetTeardropParams(), aNestLevel+1 );
2036 }
2037 }
2038 else if( aTrack->Type() == PCB_ARC_T )
2039 {
2040 const PCB_ARC* arc = static_cast<const PCB_ARC*>( aTrack );
2041
2042 m_out->Print( aNestLevel, "(arc%s (start %s) (mid %s) (end %s) (width %s)",
2043 arc->IsLocked() ? " locked" : "",
2044 formatInternalUnits( arc->GetStart() ).c_str(),
2045 formatInternalUnits( arc->GetMid() ).c_str(),
2046 formatInternalUnits( arc->GetEnd() ).c_str(),
2047 formatInternalUnits( arc->GetWidth() ).c_str() );
2048
2049 m_out->Print( 0, " (layer %s)", m_out->Quotew( LSET::Name( arc->GetLayer() ) ).c_str() );
2050 }
2051 else
2052 {
2053 m_out->Print( aNestLevel, "(segment%s (start %s) (end %s) (width %s)",
2054 aTrack->IsLocked() ? " locked" : "",
2055 formatInternalUnits( aTrack->GetStart() ).c_str(),
2056 formatInternalUnits( aTrack->GetEnd() ).c_str(),
2057 formatInternalUnits( aTrack->GetWidth() ).c_str() );
2058
2059 m_out->Print( 0, " (layer %s)", m_out->Quotew( LSET::Name( aTrack->GetLayer() ) ).c_str() );
2060 }
2061
2062 m_out->Print( 0, " (net %d)", m_mapping->Translate( aTrack->GetNetCode() ) );
2063
2064 m_out->Print( 0, " (tstamp %s)", TO_UTF8( aTrack->m_Uuid.AsString() ) );
2065
2066 m_out->Print( 0, ")\n" );
2067}
2068
2069
2070void PCB_PLUGIN::format( const ZONE* aZone, int aNestLevel ) const
2071{
2072 // Save the NET info.
2073 // For keepout and non copper zones, net code and net name are irrelevant
2074 // so be sure a dummy value is stored, just for ZONE compatibility
2075 // (perhaps netcode and netname should be not stored)
2076 bool has_no_net = aZone->GetIsRuleArea() || !aZone->IsOnCopperLayer();
2077
2078 m_out->Print( aNestLevel, "(zone%s (net %d) (net_name %s)",
2079 aZone->IsLocked() ? " locked" : "",
2080 has_no_net ? 0 : m_mapping->Translate( aZone->GetNetCode() ),
2081 m_out->Quotew( has_no_net ? wxString( wxT("") ) : aZone->GetNetname() ).c_str() );
2082
2083 // If a zone exists on multiple layers, format accordingly
2084 if( aZone->GetLayerSet().count() > 1 )
2085 {
2086 formatLayers( aZone->GetLayerSet() );
2087 }
2088 else
2089 {
2090 formatLayer( aZone->GetFirstLayer() );
2091 }
2092
2093 m_out->Print( 0, " (tstamp %s)", TO_UTF8( aZone->m_Uuid.AsString() ) );
2094
2095 if( !aZone->GetZoneName().empty() )
2096 m_out->Print( 0, " (name %s)", m_out->Quotew( aZone->GetZoneName() ).c_str() );
2097
2098 // Save the outline aux info
2099 std::string hatch;
2100
2101 switch( aZone->GetHatchStyle() )
2102 {
2103 default:
2104 case ZONE_BORDER_DISPLAY_STYLE::NO_HATCH: hatch = "none"; break;
2105 case ZONE_BORDER_DISPLAY_STYLE::DIAGONAL_EDGE: hatch = "edge"; break;
2106 case ZONE_BORDER_DISPLAY_STYLE::DIAGONAL_FULL: hatch = "full"; break;
2107 }
2108
2109 m_out->Print( 0, " (hatch %s %s)\n", hatch.c_str(),
2110 formatInternalUnits( aZone->GetBorderHatchPitch() ).c_str() );
2111
2112 if( aZone->GetAssignedPriority() > 0 )
2113 m_out->Print( aNestLevel+1, "(priority %d)\n", aZone->GetAssignedPriority() );
2114
2115 // Add teardrop keywords in file: (attr (teardrop (type xxx)))where xxx is the teardrop type
2116 if( aZone->IsTeardropArea() )
2117 {
2118 const char* td_type;
2119
2120 switch( aZone->GetTeardropAreaType() )
2121 {
2122 case TEARDROP_TYPE::TD_VIAPAD: // a teardrop on a via or pad
2123 td_type = "padvia";
2124 break;
2125
2126 default:
2127 case TEARDROP_TYPE::TD_TRACKEND: // a teardrop on a track end
2128 td_type = "track_end";
2129 break;
2130 }
2131
2132 m_out->Print( aNestLevel+1, "(attr (teardrop (type %s)))\n", td_type );
2133 }
2134
2135 m_out->Print( aNestLevel+1, "(connect_pads" );
2136
2137 switch( aZone->GetPadConnection() )
2138 {
2139 default:
2140 case ZONE_CONNECTION::THERMAL: // Default option not saved or loaded.
2141 break;
2142
2143 case ZONE_CONNECTION::THT_THERMAL:
2144 m_out->Print( 0, " thru_hole_only" );
2145 break;
2146
2147 case ZONE_CONNECTION::FULL:
2148 m_out->Print( 0, " yes" );
2149 break;
2150
2151 case ZONE_CONNECTION::NONE:
2152 m_out->Print( 0, " no" );
2153 break;
2154 }
2155
2156 m_out->Print( 0, " (clearance %s))\n", formatInternalUnits( aZone->GetLocalClearance() ).c_str() );
2157
2158 m_out->Print( aNestLevel+1, "(min_thickness %s)", formatInternalUnits( aZone->GetMinThickness() ).c_str() );
2159
2160 // We continue to write this for 3rd-party parsers, but we no longer read it (as of V7).
2161 m_out->Print( 0, " (filled_areas_thickness no)" );
2162
2163 m_out->Print( 0, "\n" );
2164
2165 if( aZone->GetIsRuleArea() )
2166 {
2167 m_out->Print( aNestLevel + 1,
2168 "(keepout (tracks %s) (vias %s) (pads %s) (copperpour %s) "
2169 "(footprints %s))\n",
2170 aZone->GetDoNotAllowTracks() ? "not_allowed" : "allowed",
2171 aZone->GetDoNotAllowVias() ? "not_allowed" : "allowed",
2172 aZone->GetDoNotAllowPads() ? "not_allowed" : "allowed",
2173 aZone->GetDoNotAllowCopperPour() ? "not_allowed" : "allowed",
2174 aZone->GetDoNotAllowFootprints() ? "not_allowed" : "allowed" );
2175 }
2176
2177 m_out->Print( aNestLevel + 1, "(fill" );
2178
2179 // Default is not filled.
2180 if( aZone->IsFilled() )
2181 m_out->Print( 0, " yes" );
2182
2183 // Default is polygon filled.
2184 if( aZone->GetFillMode() == ZONE_FILL_MODE::HATCH_PATTERN )
2185 m_out->Print( 0, " (mode hatch)" );
2186
2187 m_out->Print( 0, " (thermal_gap %s) (thermal_bridge_width %s)",
2188 formatInternalUnits( aZone->GetThermalReliefGap() ).c_str(),
2189 formatInternalUnits( aZone->GetThermalReliefSpokeWidth() ).c_str() );
2190
2192 {
2193 m_out->Print( 0, " (smoothing" );
2194
2195 switch( aZone->GetCornerSmoothingType() )
2196 {
2198 m_out->Print( 0, " chamfer" );
2199 break;
2200
2202 m_out->Print( 0, " fillet" );
2203 break;
2204
2205 default:
2206 THROW_IO_ERROR( wxString::Format( _( "unknown zone corner smoothing type %d" ),
2207 aZone->GetCornerSmoothingType() ) );
2208 }
2209 m_out->Print( 0, ")" );
2210
2211 if( aZone->GetCornerRadius() != 0 )
2212 m_out->Print( 0, " (radius %s)", formatInternalUnits( aZone->GetCornerRadius() ).c_str() );
2213 }
2214
2215 if( aZone->GetIslandRemovalMode() != ISLAND_REMOVAL_MODE::ALWAYS )
2216 {
2217 m_out->Print( 0, " (island_removal_mode %d) (island_area_min %s)",
2218 static_cast<int>( aZone->GetIslandRemovalMode() ),
2220 }
2221
2222 if( aZone->GetFillMode() == ZONE_FILL_MODE::HATCH_PATTERN )
2223 {
2224 m_out->Print( 0, "\n" );
2225 m_out->Print( aNestLevel+2, "(hatch_thickness %s) (hatch_gap %s) (hatch_orientation %s)",
2226 formatInternalUnits( aZone->GetHatchThickness() ).c_str(),
2227 formatInternalUnits( aZone->GetHatchGap() ).c_str(),
2228 FormatDouble2Str( aZone->GetHatchOrientation().AsDegrees() ).c_str() );
2229
2230 if( aZone->GetHatchSmoothingLevel() > 0 )
2231 {
2232 m_out->Print( 0, "\n" );
2233 m_out->Print( aNestLevel+2, "(hatch_smoothing_level %d) (hatch_smoothing_value %s)",
2234 aZone->GetHatchSmoothingLevel(),
2235 FormatDouble2Str( aZone->GetHatchSmoothingValue() ).c_str() );
2236 }
2237
2238 m_out->Print( 0, "\n" );
2239 m_out->Print( aNestLevel+2, "(hatch_border_algorithm %s) (hatch_min_hole_area %s)",
2240 aZone->GetHatchBorderAlgorithm() ? "hatch_thickness" : "min_thickness",
2241 FormatDouble2Str( aZone->GetHatchHoleMinArea() ).c_str() );
2242 }
2243
2244 m_out->Print( 0, ")\n" );
2245
2246 if( aZone->GetNumCorners() )
2247 {
2248 SHAPE_POLY_SET::POLYGON poly = aZone->Outline()->Polygon(0);
2249
2250 for( auto& chain : poly )
2251 {
2252 m_out->Print( aNestLevel + 1, "(polygon\n" );
2253 formatPolyPts( chain, aNestLevel + 1, ADVANCED_CFG::GetCfg().m_CompactSave );
2254 m_out->Print( aNestLevel + 1, ")\n" );
2255 }
2256 }
2257
2258 // Save the PolysList (filled areas)
2259 for( PCB_LAYER_ID layer : aZone->GetLayerSet().Seq() )
2260 {
2261 const std::shared_ptr<SHAPE_POLY_SET>& fv = aZone->GetFilledPolysList( layer );
2262
2263 for( int ii = 0; ii < fv->OutlineCount(); ++ii )
2264 {
2265 m_out->Print( aNestLevel + 1, "(filled_polygon\n" );
2266 m_out->Print( aNestLevel + 2, "(layer %s)\n",
2267 m_out->Quotew( LSET::Name( layer ) ).c_str() );
2268
2269 if( aZone->IsIsland( layer, ii ) )
2270 m_out->Print( aNestLevel + 2, "(island)\n" );
2271
2272 const SHAPE_LINE_CHAIN& chain = fv->COutline( ii );
2273
2274 formatPolyPts( chain, aNestLevel + 1, ADVANCED_CFG::GetCfg().m_CompactSave );
2275 m_out->Print( aNestLevel + 1, ")\n" );
2276 }
2277 }
2278
2279 m_out->Print( aNestLevel, ")\n" );
2280}
2281
2282
2283PCB_PLUGIN::PCB_PLUGIN( int aControlFlags ) :
2284 m_cache( nullptr ),
2285 m_ctl( aControlFlags ),
2286 m_mapping( new NETINFO_MAPPING() )
2287{
2288 init( nullptr );
2289 m_out = &m_sf;
2290}
2291
2292
2294{
2295 delete m_cache;
2296 delete m_mapping;
2297}
2298
2299
2300BOARD* PCB_PLUGIN::LoadBoard( const wxString& aFileName, BOARD* aAppendToMe,
2301 const STRING_UTF8_MAP* aProperties, PROJECT* aProject,
2302 PROGRESS_REPORTER* aProgressReporter )
2303{
2304 FILE_LINE_READER reader( aFileName );
2305
2306 unsigned lineCount = 0;
2307
2308 if( aProgressReporter )
2309 {
2310 aProgressReporter->Report( wxString::Format( _( "Loading %s..." ), aFileName ) );
2311
2312 if( !aProgressReporter->KeepRefreshing() )
2313 THROW_IO_ERROR( _( "Open cancelled by user." ) );
2314
2315 while( reader.ReadLine() )
2316 lineCount++;
2317
2318 reader.Rewind();
2319 }
2320
2321 BOARD* board = DoLoad( reader, aAppendToMe, aProperties, aProgressReporter, lineCount );
2322
2323 // Give the filename to the board if it's new
2324 if( !aAppendToMe )
2325 board->SetFileName( aFileName );
2326
2327 return board;
2328}
2329
2330
2331BOARD* PCB_PLUGIN::DoLoad( LINE_READER& aReader, BOARD* aAppendToMe, const STRING_UTF8_MAP* aProperties,
2332 PROGRESS_REPORTER* aProgressReporter, unsigned aLineCount)
2333{
2334 init( aProperties );
2335
2336 PCB_PARSER parser( &aReader, aAppendToMe, m_queryUserCallback, aProgressReporter, aLineCount );
2337 BOARD* board;
2338
2339 try
2340 {
2341 board = dynamic_cast<BOARD*>( parser.Parse() );
2342 }
2343 catch( const FUTURE_FORMAT_ERROR& )
2344 {
2345 // Don't wrap a FUTURE_FORMAT_ERROR in another
2346 throw;
2347 }
2348 catch( const PARSE_ERROR& parse_error )
2349 {
2350 if( parser.IsTooRecent() )
2351 throw FUTURE_FORMAT_ERROR( parse_error, parser.GetRequiredVersion() );
2352 else
2353 throw;
2354 }
2355
2356 if( !board )
2357 {
2358 // The parser loaded something that was valid, but wasn't a board.
2359 THROW_PARSE_ERROR( _( "This file does not contain a PCB." ), parser.CurSource(),
2360 parser.CurLine(), parser.CurLineNumber(), parser.CurOffset() );
2361 }
2362
2363 return board;
2364}
2365
2366
2367void PCB_PLUGIN::init( const STRING_UTF8_MAP* aProperties )
2368{
2369 m_board = nullptr;
2370 m_reader = nullptr;
2371 m_props = aProperties;
2372}
2373
2374
2375void PCB_PLUGIN::validateCache( const wxString& aLibraryPath, bool checkModified )
2376{
2377 if( !m_cache || !m_cache->IsPath( aLibraryPath ) || ( checkModified && m_cache->IsModified() ) )
2378 {
2379 // a spectacular episode in memory management:
2380 delete m_cache;
2381 m_cache = new FP_CACHE( this, aLibraryPath );
2382 m_cache->Load();
2383 }
2384}
2385
2386
2387void PCB_PLUGIN::FootprintEnumerate( wxArrayString& aFootprintNames, const wxString& aLibPath,
2388 bool aBestEfforts, const STRING_UTF8_MAP* aProperties )
2389{
2390 LOCALE_IO toggle; // toggles on, then off, the C locale.
2391 wxDir dir( aLibPath );
2392 wxString errorMsg;
2393
2394 init( aProperties );
2395
2396 try
2397 {
2398 validateCache( aLibPath );
2399 }
2400 catch( const IO_ERROR& ioe )
2401 {
2402 errorMsg = ioe.What();
2403 }
2404
2405 // Some of the files may have been parsed correctly so we want to add the valid files to
2406 // the library.
2407
2408 for( const auto& footprint : m_cache->GetFootprints() )
2409 aFootprintNames.Add( footprint.first );
2410
2411 if( !errorMsg.IsEmpty() && !aBestEfforts )
2412 THROW_IO_ERROR( errorMsg );
2413}
2414
2415
2416const FOOTPRINT* PCB_PLUGIN::getFootprint( const wxString& aLibraryPath,
2417 const wxString& aFootprintName,
2418 const STRING_UTF8_MAP* aProperties,
2419 bool checkModified )
2420{
2421 LOCALE_IO toggle; // toggles on, then off, the C locale.
2422
2423 init( aProperties );
2424
2425 try
2426 {
2427 validateCache( aLibraryPath, checkModified );
2428 }
2429 catch( const IO_ERROR& )
2430 {
2431 // do nothing with the error
2432 }
2433
2435 FP_CACHE_FOOTPRINT_MAP::const_iterator it = footprints.find( aFootprintName );
2436
2437 if( it == footprints.end() )
2438 return nullptr;
2439
2440 return it->second->GetFootprint();
2441}
2442
2443
2444const FOOTPRINT* PCB_PLUGIN::GetEnumeratedFootprint( const wxString& aLibraryPath,
2445 const wxString& aFootprintName,
2446 const STRING_UTF8_MAP* aProperties )
2447{
2448 return getFootprint( aLibraryPath, aFootprintName, aProperties, false );
2449}
2450
2451
2452bool PCB_PLUGIN::FootprintExists( const wxString& aLibraryPath, const wxString& aFootprintName,
2453 const STRING_UTF8_MAP* aProperties )
2454{
2455 // Note: checking the cache sounds like a good idea, but won't catch files which differ
2456 // only in case.
2457 //
2458 // Since this goes out to the native filesystem, we get platform differences (ie: MSW's
2459 // case-insensitive filesystem) handled "for free".
2460 // Warning: footprint names frequently contain a point. So be careful when initializing
2461 // wxFileName, and use a CTOR with extension specified
2462 wxFileName footprintFile( aLibraryPath, aFootprintName, KiCadFootprintFileExtension );
2463
2464 return footprintFile.Exists();
2465}
2466
2467
2468FOOTPRINT* PCB_PLUGIN::ImportFootprint( const wxString& aFootprintPath, wxString& aFootprintNameOut,
2469 const STRING_UTF8_MAP* aProperties )
2470{
2471 wxString fcontents;
2472 wxFFile f( aFootprintPath );
2473
2474 if( !f.IsOpened() )
2475 return nullptr;
2476
2477 f.ReadAll( &fcontents );
2478
2479 aFootprintNameOut = wxFileName( aFootprintPath ).GetName();
2480
2481 return dynamic_cast<FOOTPRINT*>( Parse( fcontents ) );
2482}
2483
2484
2485FOOTPRINT* PCB_PLUGIN::FootprintLoad( const wxString& aLibraryPath,
2486 const wxString& aFootprintName,
2487 bool aKeepUUID,
2488 const STRING_UTF8_MAP* aProperties )
2489{
2490 const FOOTPRINT* footprint = getFootprint( aLibraryPath, aFootprintName, aProperties, true );
2491
2492 if( footprint )
2493 {
2494 FOOTPRINT* copy;
2495
2496 if( aKeepUUID )
2497 copy = static_cast<FOOTPRINT*>( footprint->Clone() );
2498 else
2499 copy = static_cast<FOOTPRINT*>( footprint->Duplicate() );
2500
2501 copy->SetParent( nullptr );
2502 return copy;
2503 }
2504
2505 return nullptr;
2506}
2507
2508
2509void PCB_PLUGIN::FootprintSave( const wxString& aLibraryPath, const FOOTPRINT* aFootprint,
2510 const STRING_UTF8_MAP* aProperties )
2511{
2512 LOCALE_IO toggle; // toggles on, then off, the C locale.
2513
2514 init( aProperties );
2515
2516 // In this public PLUGIN API function, we can safely assume it was
2517 // called for saving into a library path.
2519
2520 validateCache( aLibraryPath );
2521
2522 if( !m_cache->IsWritable() )
2523 {
2524 if( !m_cache->Exists() )
2525 {
2526 const wxString msg = wxString::Format( _( "Library '%s' does not exist.\n"
2527 "Would you like to create it?"),
2528 aLibraryPath );
2529
2530 if( !Pgm().IsGUI()
2531 || wxMessageBox( msg, _( "Library Not Found" ), wxYES_NO | wxICON_QUESTION )
2532 != wxYES )
2533 return;
2534
2535 // Save throws its own IO_ERROR on failure, so no need to recreate here
2536 m_cache->Save( nullptr );
2537 }
2538 else
2539 {
2540 wxString msg = wxString::Format( _( "Library '%s' is read only." ), aLibraryPath );
2541 THROW_IO_ERROR( msg );
2542 }
2543 }
2544
2545 wxString footprintName = aFootprint->GetFPID().GetLibItemName();
2546
2548
2549 // Quietly overwrite footprint and delete footprint file from path for any by same name.
2550 wxFileName fn( aLibraryPath, aFootprint->GetFPID().GetLibItemName(),
2552
2553 // Write through symlinks, don't replace them
2555
2556 if( !fn.IsOk() )
2557 {
2558 THROW_IO_ERROR( wxString::Format( _( "Footprint file name '%s' is not valid." ),
2559 fn.GetFullPath() ) );
2560 }
2561
2562 if( fn.FileExists() && !fn.IsFileWritable() )
2563 {
2564 THROW_IO_ERROR( wxString::Format( _( "Insufficient permissions to delete '%s'." ),
2565 fn.GetFullPath() ) );
2566 }
2567
2568 wxString fullPath = fn.GetFullPath();
2569 wxString fullName = fn.GetFullName();
2570 FP_CACHE_FOOTPRINT_MAP::const_iterator it = footprints.find( footprintName );
2571
2572 if( it != footprints.end() )
2573 {
2574 wxLogTrace( traceKicadPcbPlugin, wxT( "Removing footprint file '%s'." ), fullPath );
2575 footprints.erase( footprintName );
2576 wxRemoveFile( fullPath );
2577 }
2578
2579 // I need my own copy for the cache
2580 FOOTPRINT* footprint = static_cast<FOOTPRINT*>( aFootprint->Clone() );
2581
2582 // It's orientation should be zero and it should be on the front layer.
2583 footprint->SetOrientation( ANGLE_0 );
2584
2585 if( footprint->GetLayer() != F_Cu )
2586 {
2587 PCBNEW_SETTINGS* cfg = dynamic_cast<PCBNEW_SETTINGS*>( Kiface().KifaceSettings() );
2588
2589 if( cfg )
2590 footprint->Flip( footprint->GetPosition(), cfg->m_FlipLeftRight );
2591 else
2592 footprint->Flip( footprint->GetPosition(), false );
2593 }
2594
2595 // Detach it from the board and its group
2596 footprint->SetParent( nullptr );
2597 footprint->SetParentGroup( nullptr );
2598
2599 wxLogTrace( traceKicadPcbPlugin, wxT( "Creating s-expr footprint file '%s'." ), fullPath );
2600 footprints.insert( footprintName,
2601 new FP_CACHE_ITEM( footprint, WX_FILENAME( fn.GetPath(), fullName ) ) );
2602 m_cache->Save( footprint );
2603}
2604
2605
2606void PCB_PLUGIN::FootprintDelete( const wxString& aLibraryPath, const wxString& aFootprintName,
2607 const STRING_UTF8_MAP* aProperties )
2608{
2609 LOCALE_IO toggle; // toggles on, then off, the C locale.
2610
2611 init( aProperties );
2612
2613 validateCache( aLibraryPath );
2614
2615 if( !m_cache->IsWritable() )
2616 {
2617 THROW_IO_ERROR( wxString::Format( _( "Library '%s' is read only." ),
2618 aLibraryPath.GetData() ) );
2619 }
2620
2621 m_cache->Remove( aFootprintName );
2622}
2623
2624
2625
2626long long PCB_PLUGIN::GetLibraryTimestamp( const wxString& aLibraryPath ) const
2627{
2628 return FP_CACHE::GetTimestamp( aLibraryPath );
2629}
2630
2631
2632void PCB_PLUGIN::FootprintLibCreate( const wxString& aLibraryPath, const STRING_UTF8_MAP* aProperties )
2633{
2634 if( wxDir::Exists( aLibraryPath ) )
2635 {
2636 THROW_IO_ERROR( wxString::Format( _( "Cannot overwrite library path '%s'." ),
2637 aLibraryPath.GetData() ) );
2638 }
2639
2640 LOCALE_IO toggle;
2641
2642 init( aProperties );
2643
2644 delete m_cache;
2645 m_cache = new FP_CACHE( this, aLibraryPath );
2646 m_cache->Save();
2647}
2648
2649
2650bool PCB_PLUGIN::FootprintLibDelete( const wxString& aLibraryPath, const STRING_UTF8_MAP* aProperties )
2651{
2652 wxFileName fn;
2653 fn.SetPath( aLibraryPath );
2654
2655 // Return if there is no library path to delete.
2656 if( !fn.DirExists() )
2657 return false;
2658
2659 if( !fn.IsDirWritable() )
2660 {
2661 THROW_IO_ERROR( wxString::Format( _( "Insufficient permissions to delete folder '%s'." ),
2662 aLibraryPath.GetData() ) );
2663 }
2664
2665 wxDir dir( aLibraryPath );
2666
2667 if( dir.HasSubDirs() )
2668 {
2669 THROW_IO_ERROR( wxString::Format( _( "Library folder '%s' has unexpected sub-folders." ),
2670 aLibraryPath.GetData() ) );
2671 }
2672
2673 // All the footprint files must be deleted before the directory can be deleted.
2674 if( dir.HasFiles() )
2675 {
2676 unsigned i;
2677 wxFileName tmp;
2678 wxArrayString files;
2679
2680 wxDir::GetAllFiles( aLibraryPath, &files );
2681
2682 for( i = 0; i < files.GetCount(); i++ )
2683 {
2684 tmp = files[i];
2685
2686 if( tmp.GetExt() != KiCadFootprintFileExtension )
2687 {
2688 THROW_IO_ERROR( wxString::Format( _( "Unexpected file '%s' found in library "
2689 "path '%s'." ),
2690 files[i].GetData(),
2691 aLibraryPath.GetData() ) );
2692 }
2693 }
2694
2695 for( i = 0; i < files.GetCount(); i++ )
2696 wxRemoveFile( files[i] );
2697 }
2698
2699 wxLogTrace( traceKicadPcbPlugin, wxT( "Removing footprint library '%s'." ),
2700 aLibraryPath.GetData() );
2701
2702 // Some of the more elaborate wxRemoveFile() crap puts up its own wxLog dialog
2703 // we don't want that. we want bare metal portability with no UI here.
2704 if( !wxRmdir( aLibraryPath ) )
2705 {
2706 THROW_IO_ERROR( wxString::Format( _( "Footprint library '%s' cannot be deleted." ),
2707 aLibraryPath.GetData() ) );
2708 }
2709
2710 // For some reason removing a directory in Windows is not immediately updated. This delay
2711 // prevents an error when attempting to immediately recreate the same directory when over
2712 // writing an existing library.
2713#ifdef __WINDOWS__
2714 wxMilliSleep( 250L );
2715#endif
2716
2717 if( m_cache && !m_cache->IsPath( aLibraryPath ) )
2718 {
2719 delete m_cache;
2720 m_cache = nullptr;
2721 }
2722
2723 return true;
2724}
2725
2726
2727bool PCB_PLUGIN::IsFootprintLibWritable( const wxString& aLibraryPath )
2728{
2729 LOCALE_IO toggle;
2730
2731 init( nullptr );
2732
2733 validateCache( aLibraryPath );
2734
2735 return m_cache->IsWritable();
2736}
constexpr std::size_t arrayDim(T const (&)[N]) noexcept
Returns # of elements in an array.
Definition: arraydim.h:31
constexpr EDA_IU_SCALE pcbIUScale
Definition: base_units.h:109
KIFACE_BASE & Kiface()
Global KIFACE_BASE "get" accessor.
@ ZLO_FORCE_FLASHED
Definition: board_item.h:66
static const ADVANCED_CFG & GetCfg()
Get the singleton instance's config, which is shared by all consumers.
double GetScale() const
Definition: bitmap_base.h:72
const wxMemoryBuffer & GetImageDataBuffer() const
Definition: bitmap_base.h:240
wxImage * GetImageData()
Definition: bitmap_base.h:67
TEARDROP_PARAMETERS & GetTeardropParams()
Container for design settings for a BOARD object.
int GetBoardThickness() const
The full thickness of the board including copper and masks.
const VECTOR2I & GetGridOrigin()
const VECTOR2I & GetAuxOrigin()
BOARD_STACKUP & GetStackupDescriptor()
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
Definition: board_item.h:77
virtual PCB_LAYER_ID GetLayer() const
Return the primary layer this item is on.
Definition: board_item.h:204
void SetParentGroup(PCB_GROUP *aGroup)
Definition: board_item.h:90
virtual bool IsKnockout() const
Definition: board_item.h:274
virtual const BOARD * GetBoard() const
Return the BOARD in which this BOARD_ITEM resides, or NULL if none.
Definition: board_item.cpp:45
FOOTPRINT * GetParentFootprint() const
Definition: board_item.cpp:247
VECTOR2I GetFPRelativePosition() const
Definition: board_item.cpp:261
virtual bool IsLocked() const
Definition: board_item.cpp:73
Manage layers needed to make a physical board.
void FormatBoardStackup(OUTPUTFORMATTER *aFormatter, const BOARD *aBoard, int aNestLevel) const
Write the stackup info on board file.
Information pertinent to a Pcbnew printed circuit board.
Definition: board.h:271
LSET GetEnabledLayers() const
A proxy function that calls the corresponding function in m_BoardSettings.
Definition: board.cpp:614
void SetFileName(const wxString &aFileName)
Definition: board.h:306
const PAGE_INFO & GetPageSettings() const
Definition: board.h:641
ZONES & Zones()
Definition: board.h:319
LAYER_T GetLayerType(PCB_LAYER_ID aLayer) const
Return the type of the copper layer given by aLayer.
Definition: board.cpp:535
TITLE_BLOCK & GetTitleBlock()
Definition: board.h:647
FOOTPRINTS & Footprints()
Definition: board.h:313
const std::map< wxString, wxString > & GetProperties() const
Definition: board.h:340
GROUPS & Groups()
The groups must maintain the following invariants.
Definition: board.h:335
TRACKS & Tracks()
Definition: board.h:310
DRAWINGS & Drawings()
Definition: board.h:316
const PCB_PLOT_PARAMS & GetPlotOptions() const
Definition: board.h:644
const wxString GetLayerName(PCB_LAYER_ID aLayer) const
Return the name of a aLayer.
Definition: board.cpp:501
bool LegacyTeardrops() const
Definition: board.h:1175
wxString GroupsSanityCheck(bool repair=false)
Consistency check of internal m_groups structure.
Definition: board.cpp:2206
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Definition: board.cpp:731
double AsDegrees() const
Definition: eda_angle.h:149
bool IsZero() const
Definition: eda_angle.h:169
EDA_ANGLE Normalize720()
Definition: eda_angle.h:299
const KIID m_Uuid
Definition: eda_item.h:482
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:97
virtual void SetParent(EDA_ITEM *aParent)
Definition: eda_item.h:100
virtual wxString GetClass() const =0
Return the class name.
const VECTOR2I & GetBezierC2() const
Definition: eda_shape.h:183
SHAPE_POLY_SET & GetPolyShape()
Definition: eda_shape.h:256
bool IsFilled() const
Definition: eda_shape.h:91
SHAPE_T GetShape() const
Definition: eda_shape.h:117
const VECTOR2I & GetEnd() const
Return the ending point of the graphic.
Definition: eda_shape.h:149
const VECTOR2I & GetStart() const
Return the starting point of the graphic.
Definition: eda_shape.h:124
wxString SHAPE_T_asString() const
Definition: eda_shape.cpp:87
const VECTOR2I & GetBezierC1() const
Definition: eda_shape.h:180
bool IsPolyShapeValid() const
Definition: eda_shape.cpp:1290
VECTOR2I GetArcMid() const
Definition: eda_shape.cpp:558
A mix-in class (via multiple inheritance) that handles texts such as labels, parts,...
Definition: eda_text.h:80
const VECTOR2I & GetTextPos() const
Definition: eda_text.h:219
const EDA_ANGLE & GetTextAngle() const
Definition: eda_text.h:131
virtual const wxString & GetText() const
Return the string associated with the text object.
Definition: eda_text.h:95
bool IsKeepUpright() const
Definition: eda_text.h:166
virtual bool IsVisible() const
Definition: eda_text.h:147
KIFONT::FONT * GetFont() const
Definition: eda_text.h:199
std::vector< std::unique_ptr< KIFONT::GLYPH > > * GetRenderCache(const KIFONT::FONT *aFont, const wxString &forResolvedText, const VECTOR2I &aOffset={ 0, 0 }) const
Definition: eda_text.cpp:491
virtual EDA_ANGLE GetDrawRotation() const
Definition: eda_text.h:315
virtual wxString GetShownText(bool aAllowExtraText, int aDepth=0) const
Return the string actually shown after processing of the base text.
Definition: eda_text.h:106
int GetTextThickness() const
Definition: eda_text.h:123
A LINE_READER that reads from an open file.
Definition: richio.h:185
void Rewind()
Rewind the file and resets the line number back to zero.
Definition: richio.h:234
char * ReadLine() override
Read a line of text into the buffer and increments the line number counter.
Definition: richio.cpp:261
Used for text file output.
Definition: richio.h:469
void SetFPID(const LIB_ID &aFPID)
Definition: footprint.h:231
wxString GetLibDescription() const
Definition: footprint.h:236
EDA_ANGLE GetOrientation() const
Definition: footprint.h:209
ZONES & Zones()
Definition: footprint.h:194
void SetOrientation(const EDA_ANGLE &aNewAngle)
Definition: footprint.cpp:2016
wxString GetSheetname() const
Definition: footprint.h:245
int GetLocalClearance() const
Definition: footprint.h:254
EDA_ITEM * Clone() const override
Create a duplicate of this item with linked list members set to NULL.
Definition: footprint.cpp:1674
double GetLocalSolderPasteMarginRatio() const
Definition: footprint.h:268
PCB_FIELD & Value()
read/write accessors:
Definition: footprint.h:589
BOARD_ITEM * Duplicate() const override
Create a copy of this BOARD_ITEM.
Definition: footprint.cpp:2044
int GetAttributes() const
Definition: footprint.h:274
PCB_LAYER_ID GetLayer() const override
Return the primary layer this item is on.
Definition: footprint.h:218
LSET GetPrivateLayers() const
Definition: footprint.h:125
wxString GetSheetfile() const
Definition: footprint.h:248
PADS & Pads()
Definition: footprint.h:188
int GetLocalSolderPasteMargin() const
Definition: footprint.h:265
const std::vector< wxString > & GetNetTiePadGroups() const
Definition: footprint.h:296
const LIB_ID & GetFPID() const
Definition: footprint.h:230
bool IsLocked() const override
Definition: footprint.h:362
void GetFields(std::vector< PCB_FIELD * > &aVector, bool aVisibleOnly)
Populate a std::vector with PCB_TEXTs.
Definition: footprint.cpp:318
PCB_FIELD & Reference()
Definition: footprint.h:590
bool IsNetTie() const
Definition: footprint.h:281
GROUPS & Groups()
Definition: footprint.h:197
const wxArrayString * GetInitialComments() const
Return the initial comments block or NULL if none, without transfer of ownership.
Definition: footprint.h:895
std::vector< FP_3DMODEL > & Models()
Definition: footprint.h:202
void Flip(const VECTOR2I &aCentre, bool aFlipLeftRight) override
Flip this object, i.e.
Definition: footprint.cpp:1884
ZONE_CONNECTION GetZoneConnection() const
Definition: footprint.h:272
const KIID_PATH & GetPath() const
Definition: footprint.h:242
wxString GetKeywords() const
Definition: footprint.h:239
bool IsPlaced() const
Definition: footprint.h:385
VECTOR2I GetPosition() const override
Definition: footprint.h:206
DRAWINGS & GraphicalItems()
Definition: footprint.h:191
int GetLocalSolderMaskMargin() const
Definition: footprint.h:251
Helper class for creating a footprint library cache.
Definition: pcb_plugin.h:184
FP_CACHE_ITEM(FOOTPRINT *aFootprint, const WX_FILENAME &aFileName)
Definition: pcb_plugin.cpp:68
static long long GetTimestamp(const wxString &aLibPath)
Generate a timestamp representing all source files in the cache (including the parent directory).
Definition: pcb_plugin.cpp:264
FP_CACHE_FOOTPRINT_MAP & GetFootprints()
Definition: pcb_plugin.h:219
bool Exists() const
Definition: pcb_plugin.h:217
void Save(FOOTPRINT *aFootprint=nullptr)
Save the footprint cache or a single footprint from it to disk.
Definition: pcb_plugin.cpp:84
bool IsModified()
Return true if the cache is not up-to-date.
Definition: pcb_plugin.cpp:256
long long m_cache_timestamp
Definition: pcb_plugin.h:207
bool m_cache_dirty
Definition: pcb_plugin.h:205
wxString m_lib_raw_path
Definition: pcb_plugin.h:202
void SetPath(const wxString &aPath)
Definition: pcb_plugin.cpp:243
PCB_PLUGIN * m_owner
Definition: pcb_plugin.h:200
FP_CACHE(PCB_PLUGIN *aOwner, const wxString &aLibraryPath)
Definition: pcb_plugin.cpp:74
wxFileName m_lib_path
Definition: pcb_plugin.h:201
bool IsPath(const wxString &aPath) const
Check if aPath is the same as the current cache path.
Definition: pcb_plugin.cpp:237
void Load()
Definition: pcb_plugin.cpp:154
FP_CACHE_FOOTPRINT_MAP m_footprints
Definition: pcb_plugin.h:203
bool IsWritable() const
Definition: pcb_plugin.h:215
void Remove(const wxString &aFootprintName)
Definition: pcb_plugin.cpp:218
Hold an error message and may be used when throwing exceptions containing meaningful error messages.
Definition: ki_exception.h:76
virtual const wxString What() const
A composite of Problem() and Where()
Definition: exceptions.cpp:30
APP_SETTINGS_BASE * KifaceSettings() const
Definition: kiface_base.h:95
virtual bool IsOutline() const
Definition: font.h:139
virtual void SetLineWidth(float aLineWidth)
Set the line width.
wxString AsString() const
Definition: kiid.cpp:359
wxString AsString() const
Definition: kiid.cpp:257
A logical library item identifier and consists of various portions much like a URI.
Definition: lib_id.h:49
UTF8 Format() const
Definition: lib_id.cpp:118
const UTF8 & GetLibItemName() const
Definition: lib_id.h:102
An abstract class from which implementation specific LINE_READERs may be derived to read single lines...
Definition: richio.h:93
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
LSET is a set of PCB_LAYER_IDs.
Definition: layer_ids.h:552
LSEQ Seq(const PCB_LAYER_ID *aWishListSequence, unsigned aCount) const
Return an LSEQ from the union of this LSET and a desired sequence.
Definition: lset.cpp:411
LSEQ CuStack() const
Return a sequence of copper layers in starting from the front/top and extending to the back/bottom.
Definition: lset.cpp:170
static LSET AllCuMask(int aCuLayerCount=MAX_CU_LAYERS)
Return a mask holding the requested number of Cu PCB_LAYER_IDs.
Definition: lset.cpp:773
static const wxChar * Name(PCB_LAYER_ID aLayerId)
Return the fixed name association with aLayerId.
Definition: lset.cpp:82
Handle the data for a net.
Definition: netinfo.h:67
static const int UNCONNECTED
Constant that holds the "unconnected net" number (typically 0) all items "connected" to this net are ...
Definition: netinfo.h:387
void SetBoard(const BOARD *aBoard)
Set a BOARD object that is used to prepare the net code map.
Definition: netinfo.h:215
int Translate(int aNetCode) const
Translate net number according to the map prepared by Update() function.
std::string Quotew(const wxString &aWrapee) const
Definition: richio.cpp:543
int PRINTF_FUNC Print(int nestLevel, const char *fmt,...)
Format and write text to the output stream.
Definition: richio.cpp:475
virtual std::string Quotes(const std::string &aWrapee) const
Check aWrapee input string for a need to be quoted (e.g.
Definition: richio.cpp:504
Definition: pad.h:58
int GetLocalClearance(wxString *aSource) const override
Return any local clearances set in the "classic" (ie: pre-rule) system.
Definition: pad.cpp:817
PAD_PROP GetProperty() const
Definition: pad.h:375
bool GetRemoveUnconnected() const
Definition: pad.h:581
PAD_DRILL_SHAPE_T GetDrillShape() const
Definition: pad.h:355
LSET GetLayerSet() const override
Return a std::bitset of all layers on which the item physically resides.
Definition: pad.h:369
const ZONE_LAYER_OVERRIDE & GetZoneLayerOverride(PCB_LAYER_ID aLayer) const
Definition: pad.h:711
const wxString & GetPinType() const
Definition: pad.h:147
const VECTOR2I & GetDrillSize() const
Definition: pad.h:253
PAD_ATTRIB GetAttribute() const
Definition: pad.h:372
ZONE_CONNECTION GetZoneConnection() const
Definition: pad.h:494
const wxString & GetPinFunction() const
Definition: pad.h:141
const wxString & GetNumber() const
Definition: pad.h:130
double GetLocalSolderPasteMarginRatio() const
Definition: pad.h:397
bool IsLocked() const override
Definition: pad.cpp:155
const std::vector< std::shared_ptr< PCB_SHAPE > > & GetPrimitives() const
Accessor to the basic shape list for custom-shaped pads.
Definition: pad.h:300
EDA_ANGLE GetThermalSpokeAngle() const
Definition: pad.h:513
const VECTOR2I & GetOffset() const
Definition: pad.h:260
int GetLocalSolderMaskMargin() const
Definition: pad.h:387
bool GetKeepTopBottom() const
Definition: pad.h:587
CUST_PAD_SHAPE_IN_ZONE GetCustomShapeInZoneOpt() const
Definition: pad.h:207
const VECTOR2I & GetDelta() const
Definition: pad.h:250
PAD_SHAPE GetShape() const
Definition: pad.h:189
EDA_ANGLE GetOrientation() const
Return the rotation angle of the pad.
Definition: pad.h:341
int GetThermalSpokeWidth() const
Definition: pad.h:503
int GetLocalSolderPasteMargin() const
Definition: pad.h:394
int GetChamferPositions() const
Definition: pad.h:566
double GetRoundRectRadiusRatio() const
Definition: pad.h:547
int GetThermalGap() const
Definition: pad.h:526
const VECTOR2I & GetSize() const
Definition: pad.h:243
PAD_SHAPE GetAnchorPadShape() const
Definition: pad.h:202
double GetChamferRectRatio() const
Definition: pad.h:556
int GetPadToDieLength() const
Definition: pad.h:385
void Format(OUTPUTFORMATTER *aFormatter, int aNestLevel, int aControlBits) const
Output the page class to aFormatter in s-expression form.
Definition: page_info.cpp:274
const VECTOR2I & GetMid() const
Definition: pcb_track.h:315
Object to handle a bitmap image that can be inserted in a PCB.
Definition: pcb_bitmap.h:42
VECTOR2I GetPosition() const override
Definition: pcb_bitmap.h:136
const BITMAP_BASE * GetImage() const
Definition: pcb_bitmap.h:53
Abstract dimension API.
wxString GetOverrideText() const
wxString GetSuffix() const
int GetLineThickness() const
DIM_TEXT_POSITION GetTextPositionMode() const
bool GetKeepTextAligned() const
DIM_PRECISION GetPrecision() const
wxString GetPrefix() const
DIM_UNITS_MODE GetUnitsMode() const
DIM_UNITS_FORMAT GetUnitsFormat() const
virtual const VECTOR2I & GetStart() const
The dimension's origin is the first feature point for the dimension.
bool GetSuppressZeroes() const
int GetExtensionOffset() const
int GetArrowLength() const
bool GetOverrideTextEnabled() const
virtual const VECTOR2I & GetEnd() const
For better understanding of the points that make a dimension:
int GetHeight() const
int GetExtensionHeight() const
Mark the center of a circle or arc with a cross shape.
A leader is a dimension-like object pointing to a specific point.
DIM_TEXT_BORDER GetTextBorder() const
An orthogonal dimension is like an aligned dimension, but the extension lines are locked to the X or ...
A radial dimension indicates either the radius or diameter of an arc or circle.
int GetLeaderLength() const
A set of BOARD_ITEMs (i.e., without duplicates).
Definition: pcb_group.h:51
std::unordered_set< BOARD_ITEM * > & GetItems()
Definition: pcb_group.h:68
wxString GetName() const
Definition: pcb_group.h:65
Read a Pcbnew s-expression formatted LINE_READER object and returns the appropriate BOARD_ITEM object...
Definition: pcb_parser.h:74
bool IsTooRecent()
Return whether a version number, if any was parsed, was too recent.
Definition: pcb_parser.h:105
BOARD_ITEM * Parse()
Definition: pcb_parser.cpp:765
wxString GetRequiredVersion()
Return a string representing the version of KiCad required to open this file.
Definition: pcb_parser.cpp:229
bool IsValidBoardHeader()
Partially parse the input and check if it matches expected header.
Definition: pcb_parser.cpp:745
void Format(OUTPUTFORMATTER *aFormatter, int aNestLevel, int aControl=0) const
A PLUGIN derivation for saving and loading Pcbnew s-expression formatted files.
Definition: pcb_plugin.h:271
void formatSetup(const BOARD *aBoard, int aNestLevel=0) const
formats the board setup information
Definition: pcb_plugin.cpp:538
void FootprintSave(const wxString &aLibraryPath, const FOOTPRINT *aFootprint, const STRING_UTF8_MAP *aProperties=nullptr) override
Write aFootprint to an existing library located at aLibraryPath.
BOARD * m_board
which BOARD, no ownership here
Definition: pcb_plugin.h:440
LINE_READER * m_reader
no ownership
Definition: pcb_plugin.h:445
void init(const STRING_UTF8_MAP *aProperties)
FOOTPRINT * ImportFootprint(const wxString &aFootprintPath, wxString &aFootprintNameOut, const STRING_UTF8_MAP *aProperties=nullptr) override
Load a single footprint from aFootprintPath and put its name in aFootprintNameOut.
friend class FP_CACHE
Definition: pcb_plugin.h:436
bool FootprintLibDelete(const wxString &aLibraryPath, const STRING_UTF8_MAP *aProperties=nullptr) override
Delete an existing footprint library and returns true, or if library does not exist returns false,...
FP_CACHE * m_cache
Footprint library cache.
Definition: pcb_plugin.h:443
std::function< bool(wxString aTitle, int aIcon, wxString aMsg, wxString aAction)> m_queryUserCallback
Definition: pcb_plugin.h:454
void formatLayer(PCB_LAYER_ID aLayer, bool aIsKnockout=false) const
Definition: pcb_plugin.cpp:449
void formatPolyPts(const SHAPE_LINE_CHAIN &outline, int aNestLevel, bool aCompact, const FOOTPRINT *aParentFP=nullptr) const
Definition: pcb_plugin.cpp:457
void SaveBoard(const wxString &aFileName, BOARD *aBoard, const STRING_UTF8_MAP *aProperties=nullptr) override
Write aBoard to a storage file in a format that this PLUGIN implementation knows about or it can be u...
Definition: pcb_plugin.cpp:293
BOARD_ITEM * Parse(const wxString &aClipboardSourceInput)
Definition: pcb_plugin.cpp:333
void formatHeader(const BOARD *aBoard, int aNestLevel=0) const
writes everything that comes before the board_items, like settings and layers etc
Definition: pcb_plugin.cpp:721
void formatLayers(LSET aLayerMask, int aNestLevel=0) const
void validateCache(const wxString &aLibraryPath, bool checkModified=true)
bool CanReadBoard(const wxString &aFileName) const override
Checks if this PLUGIN can read the specified board file.
Definition: pcb_plugin.cpp:272
bool IsFootprintLibWritable(const wxString &aLibraryPath) override
Return true if the library at aLibraryPath is writable.
BOARD * LoadBoard(const wxString &aFileName, BOARD *aAppendToMe, const STRING_UTF8_MAP *aProperties=nullptr, PROJECT *aProject=nullptr, PROGRESS_REPORTER *aProgressReporter=nullptr) override
Load information from some input file format that this PLUGIN implementation knows about into either ...
void SetOutputFormatter(OUTPUTFORMATTER *aFormatter)
Definition: pcb_plugin.h:371
void formatRenderCache(const EDA_TEXT *aText, int aNestLevel) const
Definition: pcb_plugin.cpp:510
STRING_FORMATTER m_sf
Definition: pcb_plugin.h:448
OUTPUTFORMATTER * m_out
output any Format()s to this, no ownership
Definition: pcb_plugin.h:449
const FOOTPRINT * GetEnumeratedFootprint(const wxString &aLibraryPath, const wxString &aFootprintName, const STRING_UTF8_MAP *aProperties=nullptr) override
A version of FootprintLoad() for use after FootprintEnumerate() for more efficient cache management.
const STRING_UTF8_MAP * m_props
passed via Save() or Load(), no ownership, may be NULL
Definition: pcb_plugin.h:442
BOARD * DoLoad(LINE_READER &aReader, BOARD *aAppendToMe, const STRING_UTF8_MAP *aProperties, PROGRESS_REPORTER *aProgressReporter, unsigned aLineCount)
NETINFO_MAPPING * m_mapping
mapping for net codes, so only not empty net codes are stored with consecutive integers as net codes
Definition: pcb_plugin.h:451
void format(const BOARD *aBoard, int aNestLevel=0) const
Definition: pcb_plugin.cpp:773
void formatNetInformation(const BOARD *aBoard, int aNestLevel=0) const
formats the Nets and Netclasses
Definition: pcb_plugin.cpp:691
PCB_PLUGIN(int aControlFlags=CTL_FOR_BOARD)
void FootprintDelete(const wxString &aLibraryPath, const wxString &aFootprintName, const STRING_UTF8_MAP *aProperties=nullptr) override
Delete aFootprintName from the library at aLibraryPath.
bool FootprintExists(const wxString &aLibraryPath, const wxString &aFootprintName, const STRING_UTF8_MAP *aProperties=nullptr) override
Check for the existence of a footprint.
void FootprintLibCreate(const wxString &aLibraryPath, const STRING_UTF8_MAP *aProperties=nullptr) override
Create a new empty footprint library at aLibraryPath empty.
void formatProperties(const BOARD *aBoard, int aNestLevel=0) const
formats the Nets and Netclasses
Definition: pcb_plugin.cpp:707
FOOTPRINT * FootprintLoad(const wxString &aLibraryPath, const wxString &aFootprintName, bool aKeepUUID=false, const STRING_UTF8_MAP *aProperties=nullptr) override
Load a footprint having aFootprintName from the aLibraryPath containing a library format that this PL...
void formatTeardropParameters(const TEARDROP_PARAMETERS &tdParams, int aNestLevel=0) const
Definition: pcb_plugin.cpp:755
const FOOTPRINT * getFootprint(const wxString &aLibraryPath, const wxString &aFootprintName, const STRING_UTF8_MAP *aProperties, bool checkModified)
void formatBoardLayers(const BOARD *aBoard, int aNestLevel=0) const
formats the board layer information
Definition: pcb_plugin.cpp:621
void formatGeneral(const BOARD *aBoard, int aNestLevel=0) const
formats the General section of the file
Definition: pcb_plugin.cpp:601
long long GetLibraryTimestamp(const wxString &aLibraryPath) const override
Generate a timestamp representing all the files in the library (including the library directory).
void Format(const BOARD_ITEM *aItem, int aNestLevel=0) const
Output aItem to aFormatter in s-expression format.
Definition: pcb_plugin.cpp:354
void FootprintEnumerate(wxArrayString &aFootprintNames, const wxString &aLibraryPath, bool aBestEfforts, const STRING_UTF8_MAP *aProperties=nullptr) override
Return a list of footprint names contained within the library at aLibraryPath.
virtual ~PCB_PLUGIN()
STROKE_PARAMS GetStroke() const override
Definition: pcb_shape.h:82
PCB_LAYER_ID GetLayer() const override
Return the primary layer this item is on.
Definition: pcb_shape.h:67
int GetShape() const
Definition: pcb_target.h:58
int GetWidth() const
Definition: pcb_target.h:64
int GetSize() const
Definition: pcb_target.h:61
VECTOR2I GetPosition() const override
Definition: pcb_target.h:55
bool IsBorderEnabled() const
Disables the border, this is done by changing the stroke internally.
int GetWidth() const
Definition: pcb_track.h:107
const VECTOR2I & GetStart() const
Definition: pcb_track.h:113
const VECTOR2I & GetEnd() const
Definition: pcb_track.h:110
virtual bool CanReadBoard(const wxString &aFileName) const
Checks if this PLUGIN can read the specified board file.
Definition: plugin.cpp:64
A progress reporter interface for use in multi-threaded environments.
virtual bool KeepRefreshing(bool aWait=false)=0
Update the UI (if any).
virtual void Report(const wxString &aMessage)=0
Display aMessage in the progress bar dialog.
Container for project specific data.
Definition: project.h:62
const VECTOR2I & GetArcMid() const
Definition: shape_arc.h:114
const VECTOR2I & GetP1() const
Definition: shape_arc.h:113
const VECTOR2I & GetP0() const
Definition: shape_arc.h:112
Represent a polyline containing arcs as well as line segments: A chain of connected line and/or arc s...
const SHAPE_ARC & Arc(size_t aArc) const
int PointCount() const
Return the number of points (vertices) in this line chain.
ssize_t ArcIndex(size_t aSegment) const
Return the arc index for the given segment index.
const VECTOR2I & CPoint(int aIndex) const
Return a reference to a given point in the line chain.
Represent a set of closed polygons.
POLYGON & Polygon(int aIndex)
Return the aIndex-th subpolygon in the set.
std::vector< SHAPE_LINE_CHAIN > POLYGON
represents a single polygon outline with holes.
SHAPE_LINE_CHAIN & Outline(int aIndex)
Return the reference to aIndex-th outline in the set.
Is a LINE_READER that reads from a multiline 8 bit wide std::string.
Definition: richio.h:253
A name/value tuple with unique names and optional values.
void Format(OUTPUTFORMATTER *out, const EDA_IU_SCALE &aIuScale, int nestLevel) const
TEARDROP_PARAMETARS is a helper class to handle parameters needed to build teardrops for a board thes...
int m_CurveSegCount
number of segments to build the curved sides of a teardrop area must be > 2.
double m_BestWidthRatio
The height of a teardrop as ratio between height and size of pad/via.
int m_TdMaxLen
max allowed length for teardrops in IU. <= 0 to disable
bool m_AllowUseTwoTracks
True to create teardrops using 2 track segments if the first in too small.
int m_TdMaxWidth
max allowed height for teardrops in IU. <= 0 to disable
double m_BestLengthRatio
The length of a teardrop as ratio between length and size of pad/via.
double m_WidthtoSizeFilterRatio
The ratio (H/D) between the via/pad size and the track width max value to create a teardrop 1....
bool m_TdOnPadsInZones
A filter to exclude pads inside zone fills.
virtual void Format(OUTPUTFORMATTER *aFormatter, int aNestLevel, int aControlBits) const
Output the object to aFormatter in s-expression form.
Definition: title_block.cpp:30
A wrapper around a wxFileName which is much more performant with a subset of the API.
Definition: wx_filename.h:50
void SetFullName(const wxString &aFileNameAndExtension)
Definition: wx_filename.cpp:34
static void ResolvePossibleSymlinks(wxFileName &aFilename)
Definition: wx_filename.cpp:92
wxString GetPath() const
Definition: wx_filename.cpp:60
wxString GetName() const
Definition: wx_filename.cpp:47
wxString GetFullPath() const
Definition: wx_filename.cpp:66
long long GetTimestamp()
Definition: wx_filename.cpp:81
Handle a list of polygons defining a copper zone.
Definition: zone.h:72
int GetHatchBorderAlgorithm() const
Definition: zone.h:291
bool GetIsRuleArea() const
Accessors to parameters used in Rule Area zones:
Definition: zone.h:710
bool GetDoNotAllowVias() const
Definition: zone.h:712
const std::shared_ptr< SHAPE_POLY_SET > & GetFilledPolysList(PCB_LAYER_ID aLayer) const
Definition: zone.h:615
bool GetDoNotAllowPads() const
Definition: zone.h:714
bool GetDoNotAllowTracks() const
Definition: zone.h:713
bool IsFilled() const
Definition: zone.h:249
ISLAND_REMOVAL_MODE GetIslandRemovalMode() const
Definition: zone.h:724
SHAPE_POLY_SET * Outline()
Definition: zone.h:325
bool IsIsland(PCB_LAYER_ID aLayer, int aPolyIdx) const
Check if a given filled polygon is an insulated island.
Definition: zone.cpp:1092
long long int GetMinIslandArea() const
Definition: zone.h:727
int GetLocalClearance(wxString *aSource) const override
Return any local clearances set in the "classic" (ie: pre-rule) system.
Definition: zone.cpp:501
const wxString & GetZoneName() const
Definition: zone.h:131
int GetMinThickness() const
Definition: zone.h:258
ZONE_CONNECTION GetPadConnection() const
Definition: zone.h:255
int GetHatchThickness() const
Definition: zone.h:273
double GetHatchHoleMinArea() const
Definition: zone.h:288
bool IsTeardropArea() const
Definition: zone.h:694
int GetThermalReliefSpokeWidth() const
Definition: zone.h:202
int GetBorderHatchPitch() const
HatchBorder related methods.
Definition: zone.cpp:873
ZONE_BORDER_DISPLAY_STYLE GetHatchStyle() const
Definition: zone.h:593
EDA_ANGLE GetHatchOrientation() const
Definition: zone.h:279
bool GetDoNotAllowFootprints() const
Definition: zone.h:715
ZONE_FILL_MODE GetFillMode() const
Definition: zone.h:181
virtual LSET GetLayerSet() const override
Return a std::bitset of all layers on which the item physically resides.
Definition: zone.h:129
bool GetDoNotAllowCopperPour() const
Definition: zone.h:711
int GetHatchGap() const
Definition: zone.h:276
TEARDROP_TYPE GetTeardropAreaType() const
Definition: zone.h:705
double GetHatchSmoothingValue() const
Definition: zone.h:285
int GetHatchSmoothingLevel() const
Definition: zone.h:282
unsigned int GetCornerRadius() const
Definition: zone.h:665
int GetCornerSmoothingType() const
Definition: zone.h:661
bool IsOnCopperLayer() const override
Definition: zone.cpp:266
PCB_LAYER_ID GetFirstLayer() const
Definition: zone.cpp:257
int GetThermalReliefGap() const
Definition: zone.h:191
unsigned GetAssignedPriority() const
Definition: zone.h:119
int GetNumCorners(void) const
Access to m_Poly parameters.
Definition: zone.h:503
long long TimestampDir(const wxString &aDirPath, const wxString &aFilespec)
A copy of ConvertFileTimeToWx() because wxWidgets left it as a static function private to src/common/...
Definition: common.cpp:573
This file is part of the common library.
#define MIME_BASE64_LENGTH
#define _(s)
static constexpr EDA_ANGLE & ANGLE_45
Definition: eda_angle.h:438
static constexpr EDA_ANGLE & ANGLE_90
Definition: eda_angle.h:439
static constexpr EDA_ANGLE & ANGLE_0
Definition: eda_angle.h:437
#define CTL_OMIT_HIDE
Definition: eda_text.h:63
@ FP_SMD
Definition: footprint.h:73
@ FP_DNP
Definition: footprint.h:80
@ FP_ALLOW_MISSING_COURTYARD
Definition: footprint.h:79
@ FP_EXCLUDE_FROM_POS_FILES
Definition: footprint.h:74
@ FP_BOARD_ONLY
Definition: footprint.h:76
@ FP_EXCLUDE_FROM_BOM
Definition: footprint.h:75
@ FP_THROUGH_HOLE
Definition: footprint.h:72
@ FP_ALLOW_SOLDERMASK_BRIDGES
Definition: footprint.h:78
const std::string KiCadFootprintFileExtension
const wxChar *const traceKicadPcbPlugin
Flag to enable GEDA PCB plugin debug output.
#define THROW_IO_ERROR(msg)
Definition: ki_exception.h:38
#define THROW_PARSE_ERROR(aProblem, aSource, aInputLine, aLineNumber, aByteIndex)
Definition: ki_exception.h:164
PCB_LAYER_ID
A quick note on layer IDs:
Definition: layer_ids.h:60
@ User_8
Definition: layer_ids.h:131
@ F_CrtYd
Definition: layer_ids.h:118
@ B_Adhes
Definition: layer_ids.h:98
@ Edge_Cuts
Definition: layer_ids.h:114
@ Dwgs_User
Definition: layer_ids.h:110
@ F_Paste
Definition: layer_ids.h:102
@ Cmts_User
Definition: layer_ids.h:111
@ User_6
Definition: layer_ids.h:129
@ User_7
Definition: layer_ids.h:130
@ F_Adhes
Definition: layer_ids.h:99
@ B_Mask
Definition: layer_ids.h:107
@ B_Cu
Definition: layer_ids.h:96
@ User_5
Definition: layer_ids.h:128
@ Eco1_User
Definition: layer_ids.h:112
@ F_Mask
Definition: layer_ids.h:108
@ B_Paste
Definition: layer_ids.h:101
@ User_9
Definition: layer_ids.h:132
@ F_Fab
Definition: layer_ids.h:121
@ Margin
Definition: layer_ids.h:115
@ F_SilkS
Definition: layer_ids.h:105
@ B_CrtYd
Definition: layer_ids.h:117
@ Eco2_User
Definition: layer_ids.h:113
@ User_3
Definition: layer_ids.h:126
@ User_1
Definition: layer_ids.h:124
@ B_SilkS
Definition: layer_ids.h:104
@ User_4
Definition: layer_ids.h:127
@ PCB_LAYER_ID_COUNT
Definition: layer_ids.h:138
@ User_2
Definition: layer_ids.h:125
@ F_Cu
Definition: layer_ids.h:65
@ B_Fab
Definition: layer_ids.h:120
This file contains miscellaneous commonly used macros and functions.
#define UNIMPLEMENTED_FOR(type)
Definition: macros.h:96
KICOMMON_API std::string FormatInternalUnits(const EDA_IU_SCALE &aIuScale, int aValue)
Converts aValue from internal units to a string appropriate for writing to file.
Definition: eda_units.cpp:142
KICOMMON_API std::string FormatAngle(const EDA_ANGLE &aAngle)
Converts aAngle from board units to a string appropriate for writing to file.
Definition: eda_units.cpp:134
bool DuplicatePermissions(const wxString &aSrc, const wxString &aDest)
Duplicates the file security data from one file to another ensuring that they are the same between bo...
Definition: gtk/io.cpp:39
@ CUST_PAD_SHAPE_IN_ZONE_CONVEXHULL
Definition: pad.h:45
@ PAD_DRILL_SHAPE_OBLONG
Definition: pad_shapes.h:71
Class to handle a set of BOARD_ITEMs.
Pcbnew s-expression file format parser definition.
bool isDefaultTeardropParameters(const TEARDROP_PARAMETERS &tdParams)
Definition: pcb_plugin.cpp:739
std::string formatInternalUnits(int aValue)
Definition: pcb_plugin.cpp:424
#define CTL_OMIT_FOOTPRINT_VERSION
Omit the version string from the (footprint) sexpr group.
Definition: pcb_plugin.h:159
#define SEXPR_BOARD_FILE_VERSION
Current s-expression file format version. 2 was the last legacy format version.
Definition: pcb_plugin.h:143
#define CTL_OMIT_TSTAMPS
Omit component time stamp (useless in library)
Definition: pcb_plugin.h:151
#define CTL_OMIT_INITIAL_COMMENTS
omit FOOTPRINT initial comments
Definition: pcb_plugin.h:152
#define CTL_OMIT_LIBNAME
Omit lib alias when saving (used for board/not library).
Definition: pcb_plugin.h:157
#define CTL_OMIT_PATH
Omit component sheet time stamp (useless in library)
Definition: pcb_plugin.h:153
#define CTL_OMIT_AT
Omit position and rotation.
Definition: pcb_plugin.h:154
#define CTL_OMIT_PAD_NETS
Omit pads net names (useless in library)
Definition: pcb_plugin.h:150
boost::ptr_map< wxString, FP_CACHE_ITEM > FP_CACHE_FOOTPRINT_MAP
Definition: pcb_plugin.h:196
#define CTL_FOR_LIBRARY
Format output for a footprint library instead of clipboard or BOARD.
Definition: pcb_plugin.h:168
#define UNDEFINED_DRILL_DIAMETER
Definition: pcb_track.h:72
see class PGM_BASE
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.
Definition: richio.cpp:85
KIWAY Kiway & Pgm(), KFCTL_STANDALONE
The global Program "get" accessor.
Definition: single_top.cpp:115
std::string FormatDouble2Str(double aValue)
Print a float number without using scientific notation and no trailing 0 This function is intended in...
wxString EscapeString(const wxString &aSource, ESCAPE_CONTEXT aContext)
The Escape/Unescape routines use HTML-entity-reference-style encoding to handle characters which are:...
#define TO_UTF8(wxstring)
Convert a wxString to a UTF8 encoded C string for all wxWidgets build modes.
Definition: string_utils.h:378
@ CTX_QUOTED_STR
Definition: string_utils.h:57
const double IU_PER_MM
Definition: base_units.h:77
Variant of PARSE_ERROR indicating that a syntax or related error was likely caused by a file generate...
Definition: ki_exception.h:175
static const char * ShowType(LAYER_T aType)
Convert a LAYER_T enum to a string representation of the layer type.
Definition: board.cpp:562
A filename or source description, a problem input line, a line number, a byte offset,...
Definition: ki_exception.h:119
wxLogTrace helper definitions.
void RotatePoint(int *pX, int *pY, const EDA_ANGLE &aAngle)
Definition: trigo.cpp:183
@ PCB_T
Definition: typeinfo.h:82
@ PCB_SHAPE_T
class PCB_SHAPE, a segment not on copper layers
Definition: typeinfo.h:88
@ PCB_DIM_ORTHOGONAL_T
class PCB_DIM_ORTHOGONAL, a linear dimension constrained to x/y
Definition: typeinfo.h:102
@ PCB_DIM_LEADER_T
class PCB_DIM_LEADER, a leader dimension (graphic item)
Definition: typeinfo.h:99
@ PCB_VIA_T
class PCB_VIA, a via (like a track segment on a copper layer)
Definition: typeinfo.h:94
@ PCB_DIM_CENTER_T
class PCB_DIM_CENTER, a center point marking (graphic item)
Definition: typeinfo.h:100
@ PCB_GROUP_T
class PCB_GROUP, a set of BOARD_ITEMs
Definition: typeinfo.h:107
@ PCB_TEXTBOX_T
class PCB_TEXTBOX, wrapped text on a layer
Definition: typeinfo.h:92
@ PCB_ZONE_T
class ZONE, a copper pour area
Definition: typeinfo.h:104
@ PCB_TEXT_T
class PCB_TEXT, text on a layer
Definition: typeinfo.h:91
@ PCB_FIELD_T
class PCB_FIELD, text associated with a footprint property
Definition: typeinfo.h:90
@ PCB_TARGET_T
class PCB_TARGET, a target (graphic item)
Definition: typeinfo.h:103
@ PCB_FOOTPRINT_T
class FOOTPRINT, a footprint
Definition: typeinfo.h:86
@ PCB_DIM_ALIGNED_T
class PCB_DIM_ALIGNED, a linear dimension (graphic item)
Definition: typeinfo.h:98
@ PCB_BITMAP_T
class PCB_BITMAP, bitmap on a layer
Definition: typeinfo.h:89
@ PCB_PAD_T
class PAD, a pad in a footprint
Definition: typeinfo.h:87
@ PCB_ARC_T
class PCB_ARC, an arc track segment on a copper layer
Definition: typeinfo.h:95
@ PCB_TRACE_T
class PCB_TRACK, a track segment (segment on a copper layer)
Definition: typeinfo.h:93
@ PCB_DIM_RADIAL_T
class PCB_DIM_RADIAL, a radius or diameter dimension
Definition: typeinfo.h:101
VECTOR2< int > VECTOR2I
Definition: vector2d.h:588
Definition of file extensions used in Kicad.