KiCad PCB EDA Suite
Loading...
Searching...
No Matches
easypc_pcb_items.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 * Copyright The 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
27
28#ifndef EASYPC_PCB_ITEMS_H_
29#define EASYPC_PCB_ITEMS_H_
30
31#include <map>
32#include <memory>
33#include <vector>
34
35#include <geometry/eda_angle.h>
38#include <layer_ids.h>
39#include <lset.h>
40#include <math/vector2d.h>
42#include <wx/string.h>
43
48
50class FOOTPRINT;
51class LIB_ID;
52class PAD;
53class PCB_SHAPE;
54class PCB_TEXT;
55
56namespace EASYPC
57{
59struct SOURCE_SYMBOL;
60} // namespace EASYPC
61
62
63namespace EASYPC_PCB
64{
65
67struct FRAME
68{
71
73 VECTOR2I ToKiCad( int32_t aX, int32_t aY ) const { return ToKiCad( VECTOR2D( aX, aY ) ); }
74 VECTOR2I ToKiCad( const EASYPC::POINT32& aPoint ) const { return ToKiCad( aPoint.X, aPoint.Y ); }
75 VECTOR2I ToKiCad( const VECTOR2D& aPoint ) const;
76
78 int Length( int64_t aLength ) const;
79
80 static EDA_ANGLE Angle( int32_t aMilliDegrees );
81};
82
83
86{
87public:
88 explicit LAYER_MAPPER( const std::vector<const EASYPC::SOURCE_LAYER*>& aLayers );
89
90 std::vector<INPUT_LAYER_DESC> Describe() const;
91
92 void ApplyUserMapping( const std::map<wxString, PCB_LAYER_ID>& aMapping );
93
95 PCB_LAYER_ID Map( const EASYPC::OBJECT* aLayer ) const;
96
98 LSET PadLayers( const EASYPC::OBJECT* aLayer, bool aComponentPad ) const;
99
100 const EASYPC::SOURCE_LAYER* Native( PCB_LAYER_ID aLayer ) const;
101
103 int32_t GrowByLayer( const EASYPC::SOURCE_LAYER* aLayer, int32_t aSize ) const;
104
105 int CopperCount() const { return m_copperCount; }
106
107private:
108 std::vector<const EASYPC::SOURCE_LAYER*> m_layers;
109 std::map<const EASYPC::SOURCE_LAYER*, PCB_LAYER_ID> m_map;
111};
112
113
119{
123 std::vector<VECTOR2I> Points;
124
125 bool IsArc() const { return Points.empty(); }
126};
127
128ARC_FORM ArcForm( const EASYPC::POINT32& aStart, const EASYPC::POINT32& aEnd, int32_t aArcAngle, bool aAnticlockwise,
129 const FRAME& aFrame );
130
132SHAPE_POLY_SET ShapeToPolySet( const EASYPC::SOURCE_DESIGN_SHAPE& aShape, const FRAME& aFrame );
133
135SHAPE_POLY_SET ShapeItemArea( const EASYPC::SOURCE_SHAPE_ITEM& aItem, const FRAME& aFrame, int aMaxError );
136
138std::vector<PCB_SHAPE*> AddShapeItem( BOARD_ITEM_CONTAINER& aContainer, const EASYPC::SOURCE_SHAPE_ITEM& aItem,
139 const FRAME& aFrame, const LAYER_MAPPER& aLayers,
140 PCB_LAYER_ID aLayer = UNDEFINED_LAYER );
141
143std::unique_ptr<PAD> CreatePad( FOOTPRINT* aParent, const EASYPC::SOURCE_FREE_PAD& aPad,
144 const EASYPC::SOURCE_PAD_STYLE& aStyle, const FRAME& aFrame,
145 const LAYER_MAPPER& aLayers );
146
148bool ApplyTextPosition( PCB_TEXT& aText, const EASYPC::SOURCE_TEXT_POSITION& aPosition, const FRAME& aFrame,
149 const LAYER_MAPPER& aLayers );
150
152 const wxString& aText, const FRAME& aFrame, const LAYER_MAPPER& aLayers );
153
158std::unique_ptr<FOOTPRINT> ConvertFootprint( const EASYPC::SOURCE_SYMBOL& aSymbol, const LAYER_MAPPER& aLayers,
159 const LIB_ID& aId,
160 const EASYPC::SOURCE_PCB_COMPONENT* aComponent = nullptr,
161 std::map<const EASYPC::SOURCE_FREE_PAD*, PAD*>* aPadMap = nullptr );
162
163} // namespace EASYPC_PCB
164
165#endif // EASYPC_PCB_ITEMS_H_
Abstract interface for BOARD_ITEMs capable of storing other items inside.
LSET PadLayers(const EASYPC::OBJECT *aLayer, bool aComponentPad) const
The copper aLayer (a layer or a set) covers, with the mask and paste layers whose type plots such pad...
std::map< const EASYPC::SOURCE_LAYER *, PCB_LAYER_ID > m_map
int32_t GrowByLayer(const EASYPC::SOURCE_LAYER *aLayer, int32_t aSize) const
aSize grown on each side by aLayer's type oversize, fixed or a percentage of the size
std::vector< INPUT_LAYER_DESC > Describe() const
std::vector< const EASYPC::SOURCE_LAYER * > m_layers
PCB_LAYER_ID Map(const EASYPC::OBJECT *aLayer) const
UNDEFINED_LAYER when the native layer has no KiCad layer.
const EASYPC::SOURCE_LAYER * Native(PCB_LAYER_ID aLayer) const
void ApplyUserMapping(const std::map< wxString, PCB_LAYER_ID > &aMapping)
LAYER_MAPPER(const std::vector< const EASYPC::SOURCE_LAYER * > &aLayers)
A logical library item identifier and consists of various portions much like a URI.
Definition lib_id.h:45
LSET is a set of PCB_LAYER_IDs.
Definition lset.h:37
Definition pad.h:61
Represent a set of closed polygons.
Shapes, vertices and the free-standing drawn items.
Free pads, apart because they derive from a connectivity class.
Design items, attributes, styles, layers, net classes and spacings.
Design units of 100 nm and angles of thousandths of a degree, anticlockwise from +X with Y up.
PCB_LAYER_ID
A quick note on layer IDs:
Definition layer_ids.h:56
@ UNDEFINED_LAYER
Definition layer_ids.h:57
bool ApplyTextPosition(PCB_TEXT &aText, const SOURCE_TEXT_POSITION &aPosition, const FRAME &aFrame, const LAYER_MAPPER &aLayers)
Place and size a text from its stored position and style; false when its layer has no KiCad layer.
std::unique_ptr< FOOTPRINT > ConvertFootprint(const SOURCE_SYMBOL &aSymbol, const LAYER_MAPPER &aLayers, const LIB_ID &aId, const SOURCE_PCB_COMPONENT *aComponent, std::map< const SOURCE_FREE_PAD *, PAD * > *aPadMap)
A footprint in symbol coordinates.
SHAPE_POLY_SET ShapeToPolySet(const SOURCE_DESIGN_SHAPE &aShape, const FRAME &aFrame)
A closed shape and its cutouts as an outline with holes.
std::unique_ptr< PAD > CreatePad(FOOTPRINT *aParent, const SOURCE_FREE_PAD &aPad, const SOURCE_PAD_STYLE &aStyle, const FRAME &aFrame, const LAYER_MAPPER &aLayers)
A pad with its style's per-layer exceptions; a mask or paste exception becomes a separate opening on ...
PCB_TEXT * AddText(BOARD_ITEM_CONTAINER &aContainer, const SOURCE_TEXT_POSITION &aPosition, const wxString &aText, const FRAME &aFrame, const LAYER_MAPPER &aLayers)
ARC_FORM ArcForm(const POINT32 &aStart, const POINT32 &aEnd, int32_t aArcAngle, bool aAnticlockwise, const FRAME &aFrame)
std::vector< PCB_SHAPE * > AddShapeItem(BOARD_ITEM_CONTAINER &aContainer, const SOURCE_SHAPE_ITEM &aItem, const FRAME &aFrame, const LAYER_MAPPER &aLayers, PCB_LAYER_ID aLayer)
Add a shape item as one filled polygon, a circle, or one shape per span; aLayer overrides the item's ...
SHAPE_POLY_SET ShapeItemArea(const SOURCE_SHAPE_ITEM &aItem, const FRAME &aFrame, int aMaxError)
The copper a shape item plots: its filled region and every span stroked at the line width with round ...
Root of every deserialized object.
A point read as two int32 values.
A pad of a symbol definition.
The package half of a component.
Footprints and schematic symbols alike.
A span as KiCad can hold it: a true arc, or a polyline that is the two ends of a straight span or poi...
std::vector< VECTOR2I > Points
Native to KiCad coordinates: scale by 100 nm, flip Y and move the native origin to the KiCad offset.
static EDA_ANGLE Angle(int32_t aMilliDegrees)
VECTOR2I ToKiCad(int32_t aX, int32_t aY) const
int Length(int64_t aLength) const
EASYPC::POINT32 Origin
VECTOR2I ToKiCad(const EASYPC::POINT32 &aPoint) const
VECTOR2< int32_t > VECTOR2I
Definition vector2d.h:708
VECTOR2< double > VECTOR2D
Definition vector2d.h:707