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, double aWidth ) override;
66 
67  void AddPolygon( const std::vector< VECTOR2D >& aVertices, double aWidth ) override;
68 
69  void AddText( const VECTOR2D& aOrigin, const wxString& aText,
70  double aHeight, double aWidth, double aThickness, double aOrientation,
71  EDA_TEXT_HJUSTIFY_T aHJustify, EDA_TEXT_VJUSTIFY_T aVJustify ) override;
72 
73  void AddSpline( const VECTOR2D& aStart, const VECTOR2D& aBezierControl1,
74  const VECTOR2D& aBezierControl2, const VECTOR2D& aEnd , double aWidth ) override;
75 
80  wxPoint MapCoordinate( const VECTOR2D& aCoordinate );
81 
87  int MapLineWidth( double aLineWidth );
88 
89 protected:
91  virtual std::unique_ptr<DRAWSEGMENT> createDrawing() = 0;
92 
95  virtual std::pair<std::unique_ptr<BOARD_ITEM>, EDA_TEXT*> createText() = 0;
96 
99 };
100 
101 
103 {
104 public:
106  : m_board( aBoard )
107  {
108  }
109 
110 protected:
111  std::unique_ptr<DRAWSEGMENT> createDrawing() override;
112  std::pair<std::unique_ptr<BOARD_ITEM>, EDA_TEXT*> createText() override;
113 
115 };
116 
117 
119 {
120 public:
122  : m_module( aModule )
123  {
124  }
125 
126 protected:
127  std::unique_ptr<DRAWSEGMENT> createDrawing() override;
128  std::pair<std::unique_ptr<BOARD_ITEM>, EDA_TEXT*> createText() override;
129 
131 };
132 
133 #endif /* GRAPHICS_IMPORTER_PCBNEW */
Interface that creates objects representing shapes for a given data model.
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...
void AddArc(const VECTOR2D &aCenter, const VECTOR2D &aStart, double aAngle, double aWidth) override
Creates an object representing an arc.
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, the user scale and offset
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.
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.
PCB_LAYER_ID GetLayer() const
Returns the target layer for the imported shapes.
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
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.