KiCad PCB EDA Suite
Loading...
Searching...
No Matches
pcb_io_autotrax.h
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 * Format interpretation derived from pcb-rnd src_plugins/io_autotrax:
5 * Copyright (C) 2016, 2017, 2018, 2020 Tibor 'Igor2' Palinkas
6 * Copyright (C) 2016, 2017 Erich S. Heinzle
7 * Used under GPL v2-or-later.
8 *
9 * Copyright (C) 2026 KiCad Developers, see AUTHORS.txt for contributors.
10 *
11 * This program is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU General Public License
13 * as published by the Free Software Foundation; either version 2
14 * of the License, or (at your option) any later version.
15 *
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
20 *
21 * You should have received a copy of the GNU General Public License
22 * along with this program. If not, see <https://www.gnu.org/licenses/>.
23 */
24
25#ifndef PCB_IO_AUTOTRAX_H_
26#define PCB_IO_AUTOTRAX_H_
27
28#include <map>
29
30#include <layer_ids.h>
31#include <math/util.h>
32#include <math/vector2d.h>
33#include <pcb_io/pcb_io.h>
34#include <pcb_io/pcb_io_mgr.h>
35
36#include "autotrax_model.h"
37
38class BOARD_ITEM;
39class FOOTPRINT;
40class NETINFO_ITEM;
41class PCB_TEXT;
42
43
55class PCB_IO_AUTOTRAX : public PCB_IO
56{
57public:
59 ~PCB_IO_AUTOTRAX() override;
60
62 {
63 return IO_BASE::IO_FILE_DESC( _HKI( "Protel Autotrax / Easytrax PCB files" ), { "PCB", "pcb" }, {}, true,
64 /* aCanRead */ true, /* aCanWrite */ false );
65 }
66
67 const IO_BASE::IO_FILE_DESC GetLibraryDesc() const override { return IO_BASE::IO_FILE_DESC( wxEmptyString, {} ); }
68
69 bool CanReadBoard( const wxString& aFileName ) const override;
70
71 long long GetLibraryTimestamp( const wxString& aLibraryPath ) const override { return 0; }
72
73protected:
74 void loadBoard( const wxString& aFileName, BOARD& aBoard, bool aIsNewLoad,
75 const std::map<std::string, UTF8>* aProperties = nullptr, PROJECT* aProject = nullptr ) override;
76
77private:
78 void buildBoard( const AUTOTRAX::BOARD_DATA& aData );
79
80 void buildComponent( const AUTOTRAX::COMPONENT& aComp );
81
83 void assignNets( const std::vector<AUTOTRAX::NET_NODE>& aNodes );
84
85 void emitTrack( const AUTOTRAX::TRACK& aTrack, FOOTPRINT* aFootprint );
86 void emitArc( const AUTOTRAX::ARC& aArc, FOOTPRINT* aFootprint );
87 void emitVia( const AUTOTRAX::VIA& aVia, FOOTPRINT* aFootprint );
88 void emitPad( const AUTOTRAX::PAD& aPad, FOOTPRINT* aFootprint );
89 void emitFill( const AUTOTRAX::FILL& aFill, FOOTPRINT* aFootprint );
90 void emitText( const AUTOTRAX::TEXT& aText, FOOTPRINT* aFootprint );
91
94 bool applyText( const AUTOTRAX::TEXT& aText, PCB_TEXT* aTarget );
95
98 bool mapLayer( int aLayer, const FOOTPRINT* aFootprint, PCB_LAYER_ID& aResult ) const;
99
100 NETINFO_ITEM* getNet( const wxString& aNetName );
101
102 REPORTER& reporter() const;
103
105 void reportGaps() const;
106
108 BOARD_ITEM* parentOf( FOOTPRINT* aFootprint ) const;
109
111 void addItem( BOARD_ITEM* aItem, FOOTPRINT* aFootprint );
112
114 static int toIU( double aMils ) { return KiROUND( aMils * 25400.0 ); }
115
118 VECTOR2I toBoard( double aX, double aY ) const { return VECTOR2I( toIU( aX ), m_maxY - toIU( aY ) ); }
119
120 int m_maxY = 0;
121
122 int m_targetPads = 0;
124 int m_planePads = 0;
126
127 bool m_isNewLoad = true;
129
130 std::map<wxString, NETINFO_ITEM*> m_nets;
131
132 std::multimap<wxString, FOOTPRINT*> m_footprintsByRef;
133};
134
135#endif // PCB_IO_AUTOTRAX_H_
constexpr BOX2I KiROUND(const BOX2D &aBoxD)
Definition box2.h:982
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
Definition board_item.h:84
Information pertinent to a Pcbnew printed circuit board.
Definition board.h:410
Handle the data for a net.
Definition netinfo.h:50
void buildComponent(const AUTOTRAX::COMPONENT &aComp)
NETINFO_ITEM * getNet(const wxString &aNetName)
bool CanReadBoard(const wxString &aFileName) const override
std::map< wxString, NETINFO_ITEM * > m_nets
int m_targetPads
pads with a crosshair or moire target shape
static int toIU(double aMils)
Convert a mil value to KiCad internal units (nm).
void buildBoard(const AUTOTRAX::BOARD_DATA &aData)
BOARD_ITEM * parentOf(FOOTPRINT *aFootprint) const
Parent for a primitive: the owning footprint, or the board for free items.
bool applyText(const AUTOTRAX::TEXT &aText, PCB_TEXT *aTarget)
Apply an Autotrax string record's placement, size, rotation and layer to aText.
void assignNets(const std::vector< AUTOTRAX::NET_NODE > &aNodes)
Attach each NETDEF "refdes-pad" node to the matching imported pads.
PCB_LAYER_ID m_keepoutLayer
Edge_Cuts when the keepout outlines the board.
bool mapLayer(int aLayer, const FOOTPRINT *aFootprint, PCB_LAYER_ID &aResult) const
Map an Autotrax layer number to a KiCad layer for an item owned by aFootprint, or a free item when it...
const IO_BASE::IO_FILE_DESC GetBoardFileDesc() const override
Return board file description for the PCB_IO.
void addItem(BOARD_ITEM *aItem, FOOTPRINT *aFootprint)
Attach an item to its footprint, or append it to the board.
long long GetLibraryTimestamp(const wxString &aLibraryPath) const override
Generate a timestamp representing all the files in the library (including the library directory).
int m_maxY
board Y extent in IU, used to flip the Y axis
~PCB_IO_AUTOTRAX() override
std::multimap< wxString, FOOTPRINT * > m_footprintsByRef
footprints created by this load
VECTOR2I toBoard(double aX, double aY) const
Convert an Autotrax point (mils, Y-up) to a board point (nm, Y-down).
void emitTrack(const AUTOTRAX::TRACK &aTrack, FOOTPRINT *aFootprint)
void emitFill(const AUTOTRAX::FILL &aFill, FOOTPRINT *aFootprint)
int m_unmappedItems
items on a layer with no KiCad equivalent
void emitPad(const AUTOTRAX::PAD &aPad, FOOTPRINT *aFootprint)
int m_offLayerPads
pads on a layer KiCad cannot place them on
const IO_BASE::IO_FILE_DESC GetLibraryDesc() const override
Get the descriptor for the library container that this IO plugin operates on.
void emitArc(const AUTOTRAX::ARC &aArc, FOOTPRINT *aFootprint)
void loadBoard(const wxString &aFileName, BOARD &aBoard, bool aIsNewLoad, const std::map< std::string, UTF8 > *aProperties=nullptr, PROJECT *aProject=nullptr) override
Parse aFileName into aBoard.
void emitText(const AUTOTRAX::TEXT &aText, FOOTPRINT *aFootprint)
void reportGaps() const
Report what the import dropped or could not represent.
int m_planePads
pads asking for a ground or power plane connection
void emitVia(const AUTOTRAX::VIA &aVia, FOOTPRINT *aFootprint)
REPORTER & reporter() const
PCB_IO(const wxString &aName)
Definition pcb_io.h:372
Container for project specific data.
Definition project.h:63
A pure virtual class used to derive REPORTER objects from.
Definition reporter.h:73
PCB_LAYER_ID
A quick note on layer IDs:
Definition layer_ids.h:56
@ User_1
Definition layer_ids.h:120
#define _HKI(x)
Definition page_info.cpp:40
Free or component arc (FA / CA).
Everything parsed out of an Autotrax/Easytrax file, before any KiCad object is created.
A placed component (COMP .. ENDCOMP) holding its own primitives.
Free or component rectangular fill (FF / CF), Autotrax's only pour.
Free or component pad/pin (FP / CP).
Free or component string (FS / CS).
Free or component track segment (FT / CT). All coordinates are in mils.
Free or component via (FV / CV).
Container that describes file type info.
Definition io_base.h:43
VECTOR2< int32_t > VECTOR2I
Definition vector2d.h:708