KiCad PCB EDA Suite
graphics_importer_pcbnew.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 (C) 2016 CERN
5  * @author Maciej Suminski <maciej.suminski@cern.ch>
6  * Copyright (C) 2018 KiCad Developers, see AUTHORS.txt for contributors.
7  *
8  * This program is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU General Public License
10  * as published by the Free Software Foundation; either version 2
11  * of the License, or (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program; if not, you may find one here:
20  * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
21  * or you may search the http://www.gnu.org website for the version 2 license,
22  * or you may write to the Free Software Foundation, Inc.,
23  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
24  */
25 
26 #ifndef GRAPHICS_IMPORTER_PCBNEW_H
27 #define GRAPHICS_IMPORTER_PCBNEW_H
28 
29 #include "graphics_importer.h"
30 
32 
33 class BOARD_ITEM;
34 class BOARD;
35 class MODULE;
36 class DRAWSEGMENT;
37 class EDA_TEXT;
38 
40 {
41 public:
43 
48  void SetLayer( PCB_LAYER_ID aLayer )
49  {
50  m_layer = aLayer;
51  }
52 
57  {
58  return m_layer;
59  }
60 
61  void AddLine( const VECTOR2D& aOrigin, const VECTOR2D& aEnd, double aWidth ) override;
62 
63  void AddCircle( const VECTOR2D& aOrigin, double aRadius, double aWidth ) override;
64 
65  void AddArc( const VECTOR2D& aCenter, const VECTOR2D& aStart, double aAngle,
66  double aWidth ) override;
67 
68  void AddPolygon( const std::vector< VECTOR2D >& aVertices, double aWidth ) override;
69 
70  void AddText( const VECTOR2D& aOrigin, const wxString& aText,
71  double aHeight, double aWidth, double aThickness, double aOrientation,
72  EDA_TEXT_HJUSTIFY_T aHJustify, EDA_TEXT_VJUSTIFY_T aVJustify ) override;
73 
74  void AddSpline( const VECTOR2D& aStart, const VECTOR2D& aBezierControl1,
75  const VECTOR2D& aBezierControl2, const VECTOR2D& aEnd , double aWidth ) override;
76 
81  wxPoint MapCoordinate( const VECTOR2D& aCoordinate );
82 
88  int MapLineWidth( double aLineWidth );
89 
90 protected:
92  virtual std::unique_ptr<DRAWSEGMENT> createDrawing() = 0;
93 
96  virtual std::pair<std::unique_ptr<BOARD_ITEM>, EDA_TEXT*> createText() = 0;
97 
100 };
101 
102 
104 {
105 public:
107  : m_board( aBoard )
108  {
109  }
110 
111 protected:
112  std::unique_ptr<DRAWSEGMENT> createDrawing() override;
113  std::pair<std::unique_ptr<BOARD_ITEM>, EDA_TEXT*> createText() override;
114 
116 };
117 
118 
120 {
121 public:
123  : m_module( aModule )
124  {
125  }
126 
127 protected:
128  std::unique_ptr<DRAWSEGMENT> createDrawing() override;
129  std::pair<std::unique_ptr<BOARD_ITEM>, EDA_TEXT*> createText() override;
130 
132 };
133 
134 #endif /* GRAPHICS_IMPORTER_PCBNEW */
Interface that creates objects representing shapes for a given data model.
std::pair< std::unique_ptr< BOARD_ITEM >, EDA_TEXT * > createText() override
Create an object representing a text.
EDA_TEXT_HJUSTIFY_T
Definition: eda_text.h:62
Class BOARD_ITEM is a base class for any item which can be embedded within the BOARD container class,...
PCB_LAYER_ID GetLayer() const
Returns the target layer for the imported shapes.
void AddArc(const VECTOR2D &aCenter, const VECTOR2D &aStart, double aAngle, double aWidth) override
Creates an object representing an arc.
std::unique_ptr< DRAWSEGMENT > createDrawing() override
Create an object representing a graphical shape.
void SetLayer(PCB_LAYER_ID aLayer)
Sets the target layer for the imported shapes.
wxPoint MapCoordinate(const VECTOR2D &aCoordinate)
convert a imported coordinate to a board coordinate, according to the internal units,...
Class EDA_TEXT is a mix-in class (via multiple inheritance) that handles texts such as labels,...
Definition: eda_text.h:127
int MapLineWidth(double aLineWidth)
PCB_LAYER_ID
A quick note on layer IDs:
virtual std::unique_ptr< DRAWSEGMENT > createDrawing()=0
Create an object representing a graphical shape.
std::pair< std::unique_ptr< BOARD_ITEM >, EDA_TEXT * > createText() override
Create an object representing a text.
PCB_LAYER_ID m_layer
Target layer for the imported shapes.
void AddSpline(const VECTOR2D &aStart, const VECTOR2D &aBezierControl1, const VECTOR2D &aBezierControl2, const VECTOR2D &aEnd, double aWidth) override
Creates an object representing an arc.
void AddText(const VECTOR2D &aOrigin, const wxString &aText, double aHeight, double aWidth, double aThickness, double aOrientation, EDA_TEXT_HJUSTIFY_T aHJustify, EDA_TEXT_VJUSTIFY_T aVJustify) override
Creates an object representing a text.
EDA_TEXT_VJUSTIFY_T
Definition: eda_text.h:69
std::unique_ptr< DRAWSEGMENT > createDrawing() override
Create an object representing a graphical shape.
Board layer functions and definitions.
Class BOARD holds information pertinent to a Pcbnew printed circuit board.
Definition: class_board.h:171
virtual std::pair< std::unique_ptr< BOARD_ITEM >, EDA_TEXT * > createText()=0
Create an object representing a text.
void AddPolygon(const std::vector< VECTOR2D > &aVertices, double aWidth) override
void AddCircle(const VECTOR2D &aOrigin, double aRadius, double aWidth) override
Creates an object representing a circle.
void AddLine(const VECTOR2D &aOrigin, const VECTOR2D &aEnd, double aWidth) override
Creates an object representing a line segment.