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, you may find one here:
23 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
24 * or you may search the http://www.gnu.org website for the version 2 license,
25 * or you may write to the Free Software Foundation, Inc.,
26 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
27 */
28
29#ifndef PCB_IO_AUTOTRAX_H_
30#define PCB_IO_AUTOTRAX_H_
31
32#include <map>
33
34#include <layer_ids.h>
35#include <math/util.h>
36#include <math/vector2d.h>
37#include <pcb_io/pcb_io.h>
38#include <pcb_io/pcb_io_mgr.h>
39
40#include "autotrax_model.h"
41
42class BOARD_ITEM;
43class FOOTPRINT;
44class NETINFO_ITEM;
45
46
58class PCB_IO_AUTOTRAX : public PCB_IO
59{
60public:
62 ~PCB_IO_AUTOTRAX() override;
63
65 {
66 return IO_BASE::IO_FILE_DESC( _HKI( "Protel Autotrax / Easytrax PCB files" ), { "PCB", "pcb" }, {}, true,
67 /* aCanRead */ true, /* aCanWrite */ false );
68 }
69
70 const IO_BASE::IO_FILE_DESC GetLibraryDesc() const override { return IO_BASE::IO_FILE_DESC( wxEmptyString, {} ); }
71
72 bool CanReadBoard( const wxString& aFileName ) const override;
73
74 BOARD* LoadBoard( const wxString& aFileName, BOARD* aAppendToMe,
75 const std::map<std::string, UTF8>* aProperties = nullptr, PROJECT* aProject = nullptr ) override;
76
77 long long GetLibraryTimestamp( const wxString& aLibraryPath ) const override { return 0; }
78
79private:
80 void buildBoard( const AUTOTRAX::BOARD_DATA& aData );
81
82 void buildComponent( const AUTOTRAX::COMPONENT& aComp );
83
84 void emitTrack( const AUTOTRAX::TRACK& aTrack, FOOTPRINT* aFootprint );
85 void emitArc( const AUTOTRAX::ARC& aArc, FOOTPRINT* aFootprint );
86 void emitVia( const AUTOTRAX::VIA& aVia, FOOTPRINT* aFootprint );
87 void emitPad( const AUTOTRAX::PAD& aPad, FOOTPRINT* aFootprint );
88 void emitFill( const AUTOTRAX::FILL& aFill, FOOTPRINT* aFootprint );
89 void emitText( const AUTOTRAX::TEXT& aText, FOOTPRINT* aFootprint );
90
93 bool mapLayer( int aLayer, PCB_LAYER_ID& aResult ) const;
94
95 NETINFO_ITEM* getNet( const wxString& aNetName );
96
98 BOARD_ITEM* parentOf( FOOTPRINT* aFootprint ) const;
99
101 void addItem( BOARD_ITEM* aItem, FOOTPRINT* aFootprint );
102
104 static int toIU( double aMils ) { return KiROUND( aMils * 25400.0 ); }
105
108 VECTOR2I toBoard( double aX, double aY ) const { return VECTOR2I( toIU( aX ), m_maxY - toIU( aY ) ); }
109
110 int m_maxY = 0;
111
112 std::map<wxString, NETINFO_ITEM*> m_nets;
113};
114
115#endif // PCB_IO_AUTOTRAX_H_
constexpr BOX2I KiROUND(const BOX2D &aBoxD)
Definition box2.h:990
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:323
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
Checks if this PCB_IO can read the specified board file.
std::map< wxString, NETINFO_ITEM * > m_nets
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.
const IO_BASE::IO_FILE_DESC GetBoardFileDesc() const override
Returns 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
BOARD * LoadBoard(const wxString &aFileName, BOARD *aAppendToMe, const std::map< std::string, UTF8 > *aProperties=nullptr, PROJECT *aProject=nullptr) override
Load information from some input file format that this PCB_IO implementation knows about into either ...
VECTOR2I toBoard(double aX, double aY) const
Convert an Autotrax point (mils, Y-down) to a board point (nm, Y-up).
void emitTrack(const AUTOTRAX::TRACK &aTrack, FOOTPRINT *aFootprint)
void emitFill(const AUTOTRAX::FILL &aFill, FOOTPRINT *aFootprint)
void emitPad(const AUTOTRAX::PAD &aPad, FOOTPRINT *aFootprint)
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)
bool mapLayer(int aLayer, PCB_LAYER_ID &aResult) const
Map an Autotrax layer number to a KiCad layer.
void emitText(const AUTOTRAX::TEXT &aText, FOOTPRINT *aFootprint)
void emitVia(const AUTOTRAX::VIA &aVia, FOOTPRINT *aFootprint)
PCB_IO(const wxString &aName)
Definition pcb_io.h:346
Container for project specific data.
Definition project.h:66
PCB_LAYER_ID
A quick note on layer IDs:
Definition layer_ids.h:60
#define _HKI(x)
Definition page_info.cpp:44
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:687