KiCad PCB EDA Suite
Loading...
Searching...
No Matches
pcb_io_pads_binary.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) 2026 KiCad Developers, see AUTHORS.txt for contributors.
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version 2
9 * of the License, or (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <https://www.gnu.org/licenses/>.
18 */
19
20#include "pcb_io_pads_binary.h"
21#include "pads_binary_parser.h"
22#include "pads_layer_mapper.h"
23
24#include <algorithm>
25#include <cmath>
26#include <functional>
27#include <set>
28
29#include <board.h>
30#include <pcb_track.h>
31#include <pcb_text.h>
32#include <footprint.h>
33#include <zone.h>
34
36#include <io/pads/pads_common.h>
37
38#include <netinfo.h>
39#include <wx/log.h>
40#include <wx/file.h>
41#include <wx/filename.h>
42#include <pad.h>
43#include <pcb_shape.h>
45#include <netclass.h>
46#include <geometry/eda_angle.h>
47#include <string_utils.h>
48#include <progress_reporter.h>
49#include <reporter.h>
50#include <locale_io.h>
51#include <advanced_config.h>
52#include <geometry/shape_arc.h>
53
54
56{
59 std::placeholders::_1 ) );
60}
61
62
64
65
67{
68 IO_FILE_DESC desc;
69 desc.m_FileExtensions.emplace_back( "pcb" );
70 desc.m_Description = "PADS Binary";
71 return desc;
72}
73
74
76{
77 return IO_FILE_DESC( "PADS Binary Library", { "pcb" } );
78}
79
80
81long long PCB_IO_PADS_BINARY::GetLibraryTimestamp( const wxString& aLibraryPath ) const
82{
83 return 0;
84}
85
86
87bool PCB_IO_PADS_BINARY::CanReadBoard( const wxString& aFileName ) const
88{
89 if( !PCB_IO::CanReadBoard( aFileName ) )
90 return false;
91
93}
94
95
96BOARD* PCB_IO_PADS_BINARY::LoadBoard( const wxString& aFileName, BOARD* aAppendToMe,
97 const std::map<std::string, UTF8>* aProperties,
98 PROJECT* aProject )
99{
100 LOCALE_IO setlocale;
101
102 std::unique_ptr<BOARD> board( aAppendToMe ? aAppendToMe : new BOARD() );
103
104 if( m_reporter )
105 m_reporter->Report( _( "Starting PADS binary PCB import" ), RPT_SEVERITY_INFO );
106
108 m_progressReporter->SetNumPhases( 3 );
109
111
112 try
113 {
114 parser.Parse( aFileName );
115 }
116 catch( const std::exception& e )
117 {
118 THROW_IO_ERROR( wxString::Format( "Error parsing PADS binary file: %s", e.what() ) );
119 }
120
121 m_loadBoard = board.get();
122 m_parser = &parser;
123
124 try
125 {
127 m_progressReporter->BeginPhase( 1 );
128
130 loadNets();
131
133 m_progressReporter->BeginPhase( 2 );
134
138 loadTexts();
139 loadZones();
140
142 }
143 catch( ... )
144 {
146 throw;
147 }
148
150 return board.release();
151}
152
153
155{
156 m_layerMapper.SetCopperLayerCount( m_parser->GetParameters().layer_count );
157
158 std::vector<PADS_IO::LAYER_INFO> padsLayerInfos = m_parser->GetLayerInfos();
159
160 auto convertLayerType = []( PADS_IO::PADS_LAYER_FUNCTION func ) -> PADS_LAYER_TYPE {
161 switch( func )
162 {
179 default:
181 }
182 };
183
184 for( const auto& padsInfo : padsLayerInfos )
185 {
187 info.padsLayerNum = padsInfo.number;
188 info.name = padsInfo.name;
189
190 if( padsInfo.layer_type != PADS_IO::PADS_LAYER_FUNCTION::UNKNOWN )
191 {
192 info.type = convertLayerType( padsInfo.layer_type );
193
195 {
196 if( padsInfo.number == 1 )
198 else if( padsInfo.number == m_parser->GetParameters().layer_count )
200 }
201 }
202 else
203 {
204 info.type = m_layerMapper.GetLayerType( padsInfo.number );
205 }
206
207 info.required = padsInfo.required;
208 m_layerInfos.push_back( info );
209 }
210
211 std::vector<INPUT_LAYER_DESC> inputDescs =
212 m_layerMapper.BuildInputLayerDescriptions( m_layerInfos );
213
215 m_layerMap = m_layer_mapping_handler( inputDescs );
216
217 int copperLayerCount = m_parser->GetParameters().layer_count;
218
219 if( copperLayerCount < 1 )
220 copperLayerCount = 2;
221
222 m_loadBoard->SetCopperLayerCount( copperLayerCount );
223
224 // Binary files always use BASIC units
225 m_unitConverter.SetBasicUnitsMode( true );
227
228 m_originX = m_parser->GetParameters().origin.x;
229 m_originY = m_parser->GetParameters().origin.y;
230
231 // Fall back to board outline center only when the parser found no DFT origin.
232 // The DFT origin produces exact coordinate matches; overriding it shifts all parts.
233 if( m_originX == 0.0 && m_originY == 0.0 )
234 {
235 const auto& boardOutlines = m_parser->GetBoardOutlines();
236
237 if( !boardOutlines.empty() )
238 {
239 double minX = std::numeric_limits<double>::max();
240 double maxX = std::numeric_limits<double>::lowest();
241 double minY = std::numeric_limits<double>::max();
242 double maxY = std::numeric_limits<double>::lowest();
243
244 for( const auto& outline : boardOutlines )
245 {
246 for( const auto& pt : outline.points )
247 {
248 minX = std::min( minX, pt.x );
249 maxX = std::max( maxX, pt.x );
250 minY = std::min( minY, pt.y );
251 maxY = std::max( maxY, pt.y );
252 }
253 }
254
255 if( minX < maxX && minY < maxY )
256 {
257 m_originX = ( minX + maxX ) / 2.0;
258 m_originY = ( minY + maxY ) / 2.0;
259 }
260 }
261 }
262}
263
264
266{
267 const auto& nets = m_parser->GetNets();
268
269 for( const auto& padsNet : nets )
270 ensureNet( padsNet.name );
271}
272
273
275{
276 const auto& decals = m_parser->GetPartDecals();
277 const auto& parts = m_parser->GetParts();
278
279 for( const auto& padsPart : parts )
280 {
281 FOOTPRINT* footprint = new FOOTPRINT( m_loadBoard );
282 footprint->SetReference( padsPart.name );
283
284 KIID symbolUuid = PADS_COMMON::GenerateDeterministicUuid( padsPart.name );
286 path.push_back( symbolUuid );
287 footprint->SetPath( path );
288
289 std::string decalName = padsPart.decal;
290
291 LIB_ID fpid;
292
293 if( !decalName.empty() )
294 fpid.SetLibItemName( wxString::FromUTF8( decalName ) );
295 else
296 fpid.SetLibItemName( wxString::FromUTF8( padsPart.name ) );
297
298 footprint->SetFPID( fpid );
299 footprint->SetValue( padsPart.decal );
300
301 footprint->SetPosition( VECTOR2I( scaleCoord( padsPart.location.x, true ),
302 scaleCoord( padsPart.location.y, false ) ) );
303 footprint->SetOrientation( EDA_ANGLE( padsPart.rotation, DEGREES_T ) );
304 footprint->SetLayer( F_Cu );
305
306 m_loadBoard->Add( footprint );
307
308 if( padsPart.bottom_layer )
309 footprint->Flip( footprint->GetPosition(), FLIP_DIRECTION::LEFT_RIGHT );
310 }
311}
312
313
315{
316 for( const PADS_IO::POLYLINE& polyline : m_parser->GetBoardOutlines() )
317 {
318 const auto& pts = polyline.points;
319
320 if( pts.size() < 2 )
321 continue;
322
323 for( size_t i = 0; i < pts.size() - 1; ++i )
324 {
325 const PADS_IO::ARC_POINT& p1 = pts[i];
326 const PADS_IO::ARC_POINT& p2 = pts[i + 1];
327
328 if( std::abs( p1.x - p2.x ) < 0.001 && std::abs( p1.y - p2.y ) < 0.001 )
329 continue;
330
331 PCB_SHAPE* shape = new PCB_SHAPE( m_loadBoard );
332 shape->SetShape( SHAPE_T::SEGMENT );
333 shape->SetStart( VECTOR2I( scaleCoord( p1.x, true ),
334 scaleCoord( p1.y, false ) ) );
335 shape->SetEnd( VECTOR2I( scaleCoord( p2.x, true ),
336 scaleCoord( p2.y, false ) ) );
337 shape->SetWidth( scaleSize( polyline.width ) );
338 shape->SetLayer( Edge_Cuts );
339 m_loadBoard->Add( shape );
340 }
341
342 if( polyline.closed && pts.size() > 2 )
343 {
344 const PADS_IO::ARC_POINT& pLast = pts.back();
345 const PADS_IO::ARC_POINT& pFirst = pts.front();
346
347 bool needsClosing = ( std::abs( pLast.x - pFirst.x ) > 0.001
348 || std::abs( pLast.y - pFirst.y ) > 0.001 );
349
350 if( needsClosing )
351 {
352 PCB_SHAPE* shape = new PCB_SHAPE( m_loadBoard );
353 shape->SetShape( SHAPE_T::SEGMENT );
354 shape->SetStart( VECTOR2I( scaleCoord( pLast.x, true ),
355 scaleCoord( pLast.y, false ) ) );
356 shape->SetEnd( VECTOR2I( scaleCoord( pFirst.x, true ),
357 scaleCoord( pFirst.y, false ) ) );
358 shape->SetWidth( scaleSize( polyline.width ) );
359 shape->SetLayer( Edge_Cuts );
360 m_loadBoard->Add( shape );
361 }
362 }
363 }
364}
365
366
368{
369 const auto& routes = m_parser->GetRoutes();
370 std::set<std::pair<int, int>> placedThroughVias;
371
372 for( const auto& route : routes )
373 {
374 NETINFO_ITEM* net = nullptr;
375
376 if( !route.net_name.empty() )
377 {
378 net = m_loadBoard->FindNet(
379 PADS_COMMON::ConvertInvertedNetName( route.net_name ) );
380
381 if( !net )
382 continue;
383 }
384
385 for( const auto& track_def : route.tracks )
386 {
387 if( track_def.points.size() < 2 )
388 continue;
389
390 PCB_LAYER_ID track_layer = getMappedLayer( track_def.layer );
391
392 // Binary routes with layer 0 default to F_Cu since the binary
393 // format's layer field mapping is not yet fully decoded.
394 if( !IsCopperLayer( track_layer ) )
395 {
396 if( route.net_name.empty() && track_def.layer == 0 )
397 {
398 track_layer = F_Cu;
399 }
400 else
401 {
402 if( m_reporter )
403 {
404 m_reporter->Report( wxString::Format(
405 _( "Skipping track on non-copper layer %d" ), track_def.layer ),
407 }
408
409 continue;
410 }
411 }
412
413 int track_width = scaleSize( track_def.width );
414
415 if( track_width <= 0 )
416 track_width = scaleSize( 8.0 );
417
418 for( size_t i = 0; i < track_def.points.size() - 1; ++i )
419 {
420 const PADS_IO::ARC_POINT& p1 = track_def.points[i];
421 const PADS_IO::ARC_POINT& p2 = track_def.points[i + 1];
422
423 VECTOR2I start( scaleCoord( p1.x, true ), scaleCoord( p1.y, false ) );
424 VECTOR2I end( scaleCoord( p2.x, true ), scaleCoord( p2.y, false ) );
425
426 if( ( start - end ).EuclideanNorm() < 1000 )
427 continue;
428
429 if( p2.is_arc )
430 {
431 VECTOR2I center( scaleCoord( p2.arc.cx, true ),
432 scaleCoord( p2.arc.cy, false ) );
433
434 bool clockwise = ( p2.arc.delta_angle < 0 );
435
436 SHAPE_ARC shapeArc;
437 shapeArc.ConstructFromStartEndCenter( start, end, center, clockwise,
438 track_width );
439
440 PCB_ARC* arc = new PCB_ARC( m_loadBoard, &shapeArc );
441
442 if( net )
443 arc->SetNet( net );
444
445 arc->SetWidth( track_width );
446 arc->SetLayer( track_layer );
447 m_loadBoard->Add( arc );
448 }
449 else
450 {
451 PCB_TRACK* track = new PCB_TRACK( m_loadBoard );
452
453 if( net )
454 track->SetNet( net );
455
456 track->SetWidth( track_width );
457 track->SetLayer( track_layer );
458 track->SetStart( start );
459 track->SetEnd( end );
460 m_loadBoard->Add( track );
461 }
462 }
463 }
464
465 for( const auto& via_def : route.vias )
466 {
467 VECTOR2I pos( scaleCoord( via_def.location.x, true ),
468 scaleCoord( via_def.location.y, false ) );
469
470 if( placedThroughVias.count( std::make_pair( pos.x, pos.y ) ) )
471 continue;
472
473 placedThroughVias.insert( std::make_pair( pos.x, pos.y ) );
474
475 PCB_VIA* via = new PCB_VIA( m_loadBoard );
476
477 if( net )
478 via->SetNet( net );
479
480 via->SetPosition( pos );
481 via->SetWidth( scaleSize( 20.0 ) );
482 via->SetDrill( scaleSize( 10.0 ) );
483 via->SetLayerPair( F_Cu, B_Cu );
484 via->SetViaType( VIATYPE::THROUGH );
485 m_loadBoard->Add( via );
486 }
487 }
488}
489
490
492{
493 const auto& texts = m_parser->GetTexts();
494
495 for( const auto& pads_text : texts )
496 {
497 PCB_LAYER_ID textLayer = getMappedLayer( pads_text.layer );
498
499 if( textLayer == UNDEFINED_LAYER )
500 {
501 if( m_reporter )
502 {
503 m_reporter->Report( wxString::Format(
504 _( "Text on unmapped layer %d assigned to Comments layer" ),
505 pads_text.layer ), RPT_SEVERITY_WARNING );
506 }
507
508 textLayer = Cmts_User;
509 }
510
512 text->SetText( pads_text.content );
513
514 int scaledSize = scaleSize( pads_text.height );
515 int charHeight =
516 static_cast<int>( scaledSize * ADVANCED_CFG::GetCfg().m_PadsPcbTextHeightScale );
517 int charWidth =
518 static_cast<int>( scaledSize * ADVANCED_CFG::GetCfg().m_PadsPcbTextWidthScale );
519 text->SetTextSize( VECTOR2I( charWidth, charHeight ) );
520
521 if( pads_text.width > 0 )
522 text->SetTextThickness( scaleSize( pads_text.width ) );
523
524 EDA_ANGLE textAngle( pads_text.rotation, DEGREES_T );
525 text->SetTextAngle( textAngle );
526
527 VECTOR2I pos( scaleCoord( pads_text.location.x, true ),
528 scaleCoord( pads_text.location.y, false ) );
529 VECTOR2I textShift( -ADVANCED_CFG::GetCfg().m_PadsTextAnchorOffsetNm, 0 );
530 RotatePoint( textShift, textAngle );
531 text->SetPosition( pos + textShift );
532
533 if( pads_text.hjust == "LEFT" )
534 text->SetHorizJustify( GR_TEXT_H_ALIGN_LEFT );
535 else if( pads_text.hjust == "RIGHT" )
536 text->SetHorizJustify( GR_TEXT_H_ALIGN_RIGHT );
537 else
538 text->SetHorizJustify( GR_TEXT_H_ALIGN_CENTER );
539
540 if( pads_text.vjust == "UP" )
541 text->SetVertJustify( GR_TEXT_V_ALIGN_TOP );
542 else if( pads_text.vjust == "DOWN" )
543 text->SetVertJustify( GR_TEXT_V_ALIGN_BOTTOM );
544 else
545 text->SetVertJustify( GR_TEXT_V_ALIGN_CENTER );
546
547 text->SetKeepUpright( false );
548 text->SetLayer( textLayer );
549 m_loadBoard->Add( text );
550 }
551}
552
553
555{
556 const auto& pours = m_parser->GetPours();
557 const auto& params = m_parser->GetParameters();
558
559 int maxPriority = 0;
560
561 for( const auto& pour_def : pours )
562 {
563 if( pour_def.priority > maxPriority )
564 maxPriority = pour_def.priority;
565 }
566
567 for( const auto& pour_def : pours )
568 {
569 PCB_LAYER_ID pourLayer = getMappedLayer( pour_def.layer );
570
571 if( pourLayer == UNDEFINED_LAYER )
572 {
573 if( m_reporter )
574 {
575 m_reporter->Report( wxString::Format(
576 _( "Skipping pour on unmapped layer %d" ), pour_def.layer ),
578 }
579
580 continue;
581 }
582
583 ZONE* zone = new ZONE( m_loadBoard );
584 zone->SetLayer( pourLayer );
585
586 zone->Outline()->NewOutline();
587
588 for( const auto& pt : pour_def.points )
589 {
590 zone->Outline()->Append( scaleCoord( pt.x, true ), scaleCoord( pt.y, false ) );
591 }
592
593 if( zone->GetNumCorners() == 0 )
594 {
595 delete zone;
596 continue;
597 }
598
599 if( pour_def.is_cutout )
600 {
601 zone->SetIsRuleArea( true );
602 zone->SetDoNotAllowZoneFills( true );
603 zone->SetDoNotAllowTracks( false );
604 zone->SetDoNotAllowVias( false );
605 zone->SetDoNotAllowPads( false );
606 zone->SetDoNotAllowFootprints( false );
607 zone->SetZoneName( wxString::Format( wxT( "Cutout_%s" ), pour_def.owner_pour ) );
608 }
609 else
610 {
611 NETINFO_ITEM* net = m_loadBoard->FindNet(
612 PADS_COMMON::ConvertInvertedNetName( pour_def.net_name ) );
613
614 if( net )
615 zone->SetNet( net );
616
617 int kicadPriority = maxPriority - pour_def.priority + 1;
618 zone->SetAssignedPriority( kicadPriority );
619 zone->SetMinThickness( scaleSize( pour_def.width ) );
620
621 zone->SetThermalReliefGap( scaleSize( params.thermal_min_clearance ) );
622 zone->SetThermalReliefSpokeWidth( scaleSize( params.thermal_line_width ) );
623
625 }
626
627 m_loadBoard->Add( zone );
628 }
629}
630
631
633{
634 if( !m_reporter )
635 return;
636
637 size_t trackCount = 0;
638 size_t viaCount = 0;
639
640 for( PCB_TRACK* track : m_loadBoard->Tracks() )
641 {
642 if( track->Type() == PCB_VIA_T )
643 viaCount++;
644 else
645 trackCount++;
646 }
647
648 m_reporter->Report( wxString::Format( _( "Imported %zu footprints, %d nets, %zu tracks,"
649 " %zu vias, %zu zones" ),
650 m_loadBoard->Footprints().size(),
651 m_loadBoard->GetNetCount(),
652 trackCount, viaCount,
653 m_loadBoard->Zones().size() ),
655}
656
657
658std::map<wxString, PCB_LAYER_ID> PCB_IO_PADS_BINARY::DefaultLayerMappingCallback(
659 const std::vector<INPUT_LAYER_DESC>& aInputLayerDescriptionVector )
660{
661 std::map<wxString, PCB_LAYER_ID> layerMap;
662
663 for( const INPUT_LAYER_DESC& layer : aInputLayerDescriptionVector )
664 layerMap[layer.Name] = layer.AutoMapLayer;
665
666 return layerMap;
667}
668
669
670int PCB_IO_PADS_BINARY::scaleSize( double aVal ) const
671{
672 return static_cast<int>( m_unitConverter.ToNanometersSize( aVal ) );
673}
674
675
676int PCB_IO_PADS_BINARY::scaleCoord( double aVal, bool aIsX ) const
677{
678 double origin = aIsX ? m_originX : m_originY;
679
680 long long originNm = static_cast<long long>( std::round( origin * m_scaleFactor ) );
681 long long valNm = static_cast<long long>( std::round( aVal * m_scaleFactor ) );
682
683 if( aIsX )
684 return static_cast<int>( valNm - originNm );
685 else
686 return static_cast<int>( originNm - valNm );
687}
688
689
691{
692 for( const auto& info : m_layerInfos )
693 {
694 if( info.padsLayerNum == aPadsLayer )
695 {
696 auto it = m_layerMap.find( wxString::FromUTF8( info.name ) );
697
698 if( it != m_layerMap.end() && it->second != UNDEFINED_LAYER )
699 return it->second;
700
701 return m_layerMapper.GetAutoMapLayer( aPadsLayer, info.type );
702 }
703 }
704
705 return m_layerMapper.GetAutoMapLayer( aPadsLayer );
706}
707
708
709void PCB_IO_PADS_BINARY::ensureNet( const std::string& aNetName )
710{
711 if( aNetName.empty() )
712 return;
713
714 wxString wxName = PADS_COMMON::ConvertInvertedNetName( aNetName );
715
716 if( m_loadBoard->FindNet( wxName ) == nullptr )
717 {
718 NETINFO_ITEM* net = new NETINFO_ITEM(
719 m_loadBoard, wxName,
720 static_cast<int>( m_loadBoard->GetNetCount() ) + 1 );
721 m_loadBoard->Add( net );
722 }
723}
724
725
727{
728 m_loadBoard = nullptr;
729 m_parser = nullptr;
732 m_layerInfos.clear();
733 m_scaleFactor = 0.0;
734 m_originX = 0.0;
735 m_originY = 0.0;
736 m_pinToNetMap.clear();
737}
static const ADVANCED_CFG & GetCfg()
Get the singleton instance's config, which is shared by all consumers.
virtual void SetNet(NETINFO_ITEM *aNetInfo)
Set a NET_INFO object for the item.
void SetLayer(PCB_LAYER_ID aLayer) override
Set the layer this item is on.
Information pertinent to a Pcbnew printed circuit board.
Definition board.h:372
void SetPosition(const VECTOR2I &aPos) override
void SetFPID(const LIB_ID &aFPID)
Definition footprint.h:442
void SetOrientation(const EDA_ANGLE &aNewAngle)
void SetPath(const KIID_PATH &aPath)
Definition footprint.h:465
void SetReference(const wxString &aReference)
Definition footprint.h:847
void SetValue(const wxString &aValue)
Definition footprint.h:868
void SetLayer(PCB_LAYER_ID aLayer) override
Set the layer this item is on.
void Flip(const VECTOR2I &aCentre, FLIP_DIRECTION aFlipDirection) override
Flip this object, i.e.
VECTOR2I GetPosition() const override
Definition footprint.h:403
REPORTER * m_reporter
Reporter to log errors/warnings to, may be nullptr.
Definition io_base.h:237
PROGRESS_REPORTER * m_progressReporter
Progress reporter to track the progress of the operation, may be nullptr.
Definition io_base.h:240
Definition kiid.h:44
virtual void RegisterCallback(LAYER_MAPPING_HANDLER aLayerMappingHandler)
Register a different handler to be called when mapping of input layers to KiCad layers occurs.
LAYER_MAPPING_HANDLER m_layer_mapping_handler
Callback to get layer mapping.
A logical library item identifier and consists of various portions much like a URI.
Definition lib_id.h:45
int SetLibItemName(const UTF8 &aLibItemName)
Override the library item name portion of the LIB_ID to aLibItemName.
Definition lib_id.cpp:107
Instantiate the current locale within a scope in which you are expecting exceptions to be thrown.
Definition locale_io.h:37
Handle the data for a net.
Definition netinfo.h:46
Parser for PADS binary PCB file format (.pcb).
static bool IsBinaryPadsFile(const wxString &aFileName)
Check if a file appears to be a PADS binary PCB file.
void Parse(const wxString &aFileName)
Maps PADS layer numbers and names to KiCad layer IDs.
Converts PADS file format units to KiCad internal units (nanometers).
static constexpr double BASIC_TO_NM
long long GetLibraryTimestamp(const wxString &aLibraryPath) const override
Generate a timestamp representing all the files in the library (including the library directory).
const IO_FILE_DESC GetBoardFileDesc() const override
Returns board file description for the PCB_IO.
BOARD * LoadBoard(const wxString &aFileName, BOARD *aAppendToMe, const std::map< std::string, UTF8 > *aProperties, PROJECT *aProject) override
Load information from some input file format that this PCB_IO implementation knows about into either ...
bool CanReadBoard(const wxString &aFileName) const override
Checks if this PCB_IO can read the specified board file.
~PCB_IO_PADS_BINARY() override
int scaleSize(double aVal) const
const IO_FILE_DESC GetLibraryDesc() const override
Get the descriptor for the library container that this IO plugin operates on.
const PADS_IO::BINARY_PARSER * m_parser
PCB_LAYER_ID getMappedLayer(int aPadsLayer) const
PADS_UNIT_CONVERTER m_unitConverter
void ensureNet(const std::string &aNetName)
int scaleCoord(double aVal, bool aIsX) const
std::vector< PADS_LAYER_INFO > m_layerInfos
PADS_LAYER_MAPPER m_layerMapper
std::map< wxString, PCB_LAYER_ID > m_layerMap
std::map< std::string, std::string > m_pinToNetMap
std::map< wxString, PCB_LAYER_ID > DefaultLayerMappingCallback(const std::vector< INPUT_LAYER_DESC > &aInputLayerDescriptionVector)
virtual bool CanReadBoard(const wxString &aFileName) const
Checks if this PCB_IO can read the specified board file.
Definition pcb_io.cpp:38
PCB_IO(const wxString &aName)
Definition pcb_io.h:342
void SetWidth(int aWidth) override
void SetShape(SHAPE_T aShape) override
Definition pcb_shape.h:200
void SetEnd(const VECTOR2I &aEnd) override
void SetLayer(PCB_LAYER_ID aLayer) override
Set the layer this item is on.
void SetStart(const VECTOR2I &aStart) override
void SetEnd(const VECTOR2I &aEnd)
Definition pcb_track.h:89
void SetStart(const VECTOR2I &aStart)
Definition pcb_track.h:92
virtual void SetWidth(int aWidth)
Definition pcb_track.h:86
Container for project specific data.
Definition project.h:62
SHAPE_ARC & ConstructFromStartEndCenter(const VECTOR2I &aStart, const VECTOR2I &aEnd, const VECTOR2I &aCenter, bool aClockwise=false, double aWidth=0)
Constructs this arc from the given start, end and center.
int Append(int x, int y, int aOutline=-1, int aHole=-1, bool aAllowDuplication=false)
Appends a vertex at the end of the given outline/hole (default: the last outline)
int NewOutline()
Creates a new empty polygon in the set and returns its index.
Handle a list of polygons defining a copper zone.
Definition zone.h:70
void SetDoNotAllowPads(bool aEnable)
Definition zone.h:830
void SetMinThickness(int aMinThickness)
Definition zone.h:316
void SetThermalReliefSpokeWidth(int aThermalReliefSpokeWidth)
Definition zone.h:251
virtual void SetLayer(PCB_LAYER_ID aLayer) override
Set the layer this item is on.
Definition zone.cpp:599
SHAPE_POLY_SET * Outline()
Definition zone.h:418
void SetIsRuleArea(bool aEnable)
Definition zone.h:812
void SetDoNotAllowTracks(bool aEnable)
Definition zone.h:829
void SetDoNotAllowVias(bool aEnable)
Definition zone.h:828
void SetNet(NETINFO_ITEM *aNetInfo) override
Override that drops aNetInfo when this zone is in copper-thieving fill mode.
Definition zone.cpp:590
void SetThermalReliefGap(int aThermalReliefGap)
Definition zone.h:240
void SetDoNotAllowFootprints(bool aEnable)
Definition zone.h:831
void SetDoNotAllowZoneFills(bool aEnable)
Definition zone.h:827
void SetAssignedPriority(unsigned aPriority)
Definition zone.h:117
void SetPadConnection(ZONE_CONNECTION aPadConnection)
Definition zone.h:313
void SetZoneName(const wxString &aName)
Definition zone.h:161
int GetNumCorners(void) const
Access to m_Poly parameters.
Definition zone.h:615
#define _(s)
@ DEGREES_T
Definition eda_angle.h:31
@ SEGMENT
Definition eda_shape.h:46
double m_PadsPcbTextWidthScale
PADS text width scale factor for PCB imports.
double m_PadsPcbTextHeightScale
PADS text height scale factor for PCB imports.
#define THROW_IO_ERROR(msg)
macro which captures the "call site" values of FILE_, __FUNCTION & LINE
bool IsCopperLayer(int aLayerId)
Test whether a layer is a copper layer.
Definition layer_ids.h:675
PCB_LAYER_ID
A quick note on layer IDs:
Definition layer_ids.h:56
@ Edge_Cuts
Definition layer_ids.h:108
@ Cmts_User
Definition layer_ids.h:104
@ B_Cu
Definition layer_ids.h:61
@ UNDEFINED_LAYER
Definition layer_ids.h:57
@ F_Cu
Definition layer_ids.h:60
@ LEFT_RIGHT
Flip left to right (around the Y axis)
Definition mirror.h:24
wxString ConvertInvertedNetName(const std::string &aNetName)
Convert a PADS net name to KiCad format, handling inverted signal notation.
KIID GenerateDeterministicUuid(const std::string &aIdentifier)
Generate a deterministic KIID from a PADS component identifier.
PADS_LAYER_FUNCTION
Layer types from PADS LAYER_TYPE field.
@ ASSEMBLY
Assembly drawing.
@ ROUTING
Copper routing layer.
@ PASTE_MASK
Solder paste mask.
@ MIXED
Mixed signal/plane.
@ DOCUMENTATION
Documentation layer.
@ SILK_SCREEN
Silkscreen/legend.
@ PLANE
Power/ground plane.
EDA_ANGLE abs(const EDA_ANGLE &aAngle)
Definition eda_angle.h:400
Common utilities and types for parsing PADS file formats.
PADS_LAYER_TYPE
PADS layer types.
@ RPT_SEVERITY_WARNING
@ RPT_SEVERITY_INFO
Describes an imported layer and how it could be mapped to KiCad Layers.
Container that describes file type info.
Definition io_base.h:43
wxString m_Description
Description shown in the file picker dialog.
Definition io_base.h:44
std::vector< std::string > m_FileExtensions
Filter used for file pickers if m_IsFile is true.
Definition io_base.h:47
A point that may be either a line endpoint or an arc segment.
Definition pads_parser.h:68
ARC arc
Arc parameters (only valid when is_arc is true)
Definition pads_parser.h:72
bool is_arc
True if this segment is an arc, false for line.
Definition pads_parser.h:71
double y
Endpoint Y coordinate.
Definition pads_parser.h:70
double x
Endpoint X coordinate.
Definition pads_parser.h:69
double cx
Center X coordinate.
Definition pads_parser.h:54
double delta_angle
Arc sweep angle in degrees (positive = CCW)
Definition pads_parser.h:58
double cy
Center Y coordinate.
Definition pads_parser.h:55
A polyline that may contain arc segments.
Information about a single PADS layer.
std::string path
VECTOR2I center
VECTOR2I end
@ GR_TEXT_H_ALIGN_CENTER
@ GR_TEXT_H_ALIGN_RIGHT
@ GR_TEXT_H_ALIGN_LEFT
@ GR_TEXT_V_ALIGN_BOTTOM
@ GR_TEXT_V_ALIGN_CENTER
@ GR_TEXT_V_ALIGN_TOP
void RotatePoint(int *pX, int *pY, const EDA_ANGLE &aAngle)
Calculate the new point of coord coord pX, pY, for a rotation center 0, 0.
Definition trigo.cpp:225
@ PCB_VIA_T
class PCB_VIA, a via (like a track segment on a copper layer)
Definition typeinfo.h:90
VECTOR2< int32_t > VECTOR2I
Definition vector2d.h:683
@ THERMAL
Use thermal relief for pads.
Definition zones.h:46