KiCad PCB EDA Suite
fp_shape.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) 2018 Jean-Pierre Charras, jp.charras at wanadoo.fr
5  * Copyright (C) 2013 Wayne Stambaugh <stambaughw@verizon.net>
6  * Copyright (C) 1992-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 FP_SHAPE_H
27 #define FP_SHAPE_H
28 
29 
30 #include <wx/gdicmn.h>
31 
32 #include <pcb_shape.h>
33 
34 
35 class LINE_READER;
36 class MSG_PANEL_ITEM;
37 
38 
39 class FP_SHAPE : public PCB_SHAPE
40 {
41 public:
42  FP_SHAPE( FOOTPRINT* parent, PCB_SHAPE_TYPE_T aShape = S_SEGMENT );
43 
44  // Do not create a copy constructor & operator=.
45  // The ones generated by the compiler are adequate.
46 
47  ~FP_SHAPE();
48 
49  static inline bool ClassOf( const EDA_ITEM* aItem )
50  {
51  return aItem && PCB_FP_SHAPE_T == aItem->Type();
52  }
53 
54  bool IsType( const KICAD_T aScanTypes[] ) const override
55  {
56  if( BOARD_ITEM::IsType( aScanTypes ) )
57  return true;
58 
59  for( const KICAD_T* p = aScanTypes; *p != EOT; ++p )
60  {
61  if( *p == PCB_LOCATE_GRAPHIC_T )
62  return true;
63  else if( *p == PCB_LOCATE_BOARD_EDGE_T )
64  return m_layer == Edge_Cuts;
65  }
66 
67  return false;
68  }
69 
70  void SetAngle( double aAngle, bool aUpdateEnd = true ) override;
71 
77  void Move( const wxPoint& aMoveVector ) override;
78 
85  void Mirror( const wxPoint& aCentre, bool aMirrorAroundXAxis );
86 
92  void Rotate( const wxPoint& aRotCentre, double aAngle ) override;
93 
101  void Flip( const wxPoint& aCentre, bool aFlipLeftRight ) override;
102 
103  bool IsParentFlipped() const;
104 
105  void SetStart0( const wxPoint& aPoint ) { m_Start0 = aPoint; }
106  const wxPoint& GetStart0() const { return m_Start0; }
107 
108  void SetEnd0( const wxPoint& aPoint ) { m_End0 = aPoint; }
109  const wxPoint& GetEnd0() const { return m_End0; }
110 
111  void SetThirdPoint0( const wxPoint& aPoint ){ m_ThirdPoint0 = aPoint; }
112  const wxPoint& GetThirdPoint0() const { return m_ThirdPoint0; }
113 
114  void SetBezier0_C1( const wxPoint& aPoint ) { m_Bezier0_C1 = aPoint; }
115  const wxPoint& GetBezier0_C1() const { return m_Bezier0_C1; }
116 
117  void SetBezier0_C2( const wxPoint& aPoint ) { m_Bezier0_C2 = aPoint; }
118  const wxPoint& GetBezier0_C2() const { return m_Bezier0_C2; }
119 
125  void SetLocalCoord();
126 
131  void SetDrawCoord();
132 
133  void GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITEM>& aList ) override;
134 
135  wxString GetClass() const override
136  {
137  return wxT( "MGRAPHIC" );
138  }
139 
140  wxString GetSelectMenuText( EDA_UNITS aUnits ) const override;
141 
142  BITMAP_DEF GetMenuImage() const override;
143 
144  EDA_ITEM* Clone() const override;
145 
146  double ViewGetLOD( int aLayer, KIGFX::VIEW* aView ) const override;
147 
148 #if defined(DEBUG)
149  void Show( int nestLevel, std::ostream& os ) const override { ShowDummy( os ); }
150 #endif
151 
152  wxPoint m_Start0;
153  wxPoint m_End0;
154  wxPoint m_ThirdPoint0;
155  wxPoint m_Bezier0_C1;
156  wxPoint m_Bezier0_C2;
157 };
158 
159 #endif // FP_SHAPE_H
FP_SHAPE(FOOTPRINT *parent, PCB_SHAPE_TYPE_T aShape=S_SEGMENT)
Definition: fp_shape.cpp:39
LINE_READER is an abstract class from which implementation specific LINE_READERs may be derived to re...
Definition: richio.h:82
void SetEnd0(const wxPoint &aPoint)
Definition: fp_shape.h:108
PNG memory record (file in memory).
Definition: bitmap_def.h:29
~FP_SHAPE()
Definition: fp_shape.cpp:48
void Flip(const wxPoint &aCentre, bool aFlipLeftRight) override
Flip entity relative to aCentre.
Definition: fp_shape.cpp:156
void SetBezier0_C1(const wxPoint &aPoint)
Definition: fp_shape.h:114
double ViewGetLOD(int aLayer, KIGFX::VIEW *aView) const override
Function ViewGetLOD() Returns the level of detail (LOD) of the item.
Definition: fp_shape.cpp:310
const wxPoint & GetStart0() const
Definition: fp_shape.h:106
usual segment : line with rounded ends
Definition: board_item.h:52
class FP_SHAPE, a footprint edge
Definition: typeinfo.h:94
The base class for create windows for drawing purpose.
static bool ClassOf(const EDA_ITEM *aItem)
Definition: fp_shape.h:49
void SetBezier0_C2(const wxPoint &aPoint)
Definition: fp_shape.h:117
search types array terminator (End Of Types)
Definition: typeinfo.h:82
KICAD_T
Enum KICAD_T is the set of class identification values, stored in EDA_ITEM::m_structType.
Definition: typeinfo.h:78
wxPoint m_ThirdPoint0
End point for an arc.
Definition: fp_shape.h:154
EDA_ITEM * Clone() const override
Function Clone creates a duplicate of this item with linked list members set to NULL.
Definition: fp_shape.cpp:135
PCB_SHAPE_TYPE_T
Enum PCB_SHAPE_TYPE_T is the set of shapes for PCB graphics and tracks and footprint graphics in the ...
Definition: board_item.h:50
const wxPoint & GetThirdPoint0() const
Definition: fp_shape.h:112
wxString GetClass() const override
Function GetClass returns the class name.
Definition: fp_shape.h:135
void Rotate(const wxPoint &aRotCentre, double aAngle) override
Rotate an edge of the footprint.
Definition: fp_shape.cpp:271
void SetAngle(double aAngle, bool aUpdateEnd=true) override
Function SetAngle sets the angle for arcs, and normalizes it within the range 0 - 360 degrees.
Definition: fp_shape.cpp:141
void GetMsgPanelInfo(EDA_DRAW_FRAME *aFrame, std::vector< MSG_PANEL_ITEM > &aList) override
Function GetMsgPanelInfo populates aList of MSG_PANEL_ITEM objects with it's internal state for displ...
Definition: fp_shape.cpp:110
wxPoint m_End0
End point, relative to footprint origin, orient 0.
Definition: fp_shape.h:153
wxPoint m_Start0
Start point or center, relative to footprint origin, orient 0.
Definition: fp_shape.h:152
virtual bool IsType(const KICAD_T aScanTypes[]) const
Function IsType Checks whether the item is one of the listed types.
Definition: eda_item.h:250
BITMAP_DEF GetMenuImage() const override
Function GetMenuImage returns a pointer to an image to be used in menus.
Definition: fp_shape.cpp:129
void SetDrawCoord()
Set draw coordinates (absolute values ) from relative coordinates.
Definition: fp_shape.cpp:81
void SetStart0(const wxPoint &aPoint)
Definition: fp_shape.h:105
wxPoint m_Bezier0_C2
Bezier Control Point 2, relative to footprint origin, orient 0.
Definition: fp_shape.h:156
EDA_UNITS
Definition: eda_units.h:38
bool IsParentFlipped() const
Definition: fp_shape.cpp:216
const wxPoint & GetBezier0_C2() const
Definition: fp_shape.h:118
const wxPoint & GetBezier0_C1() const
Definition: fp_shape.h:115
void Mirror(const wxPoint &aCentre, bool aMirrorAroundXAxis)
Mirror an edge of the footprint.
Definition: fp_shape.cpp:223
const wxPoint & GetEnd0() const
Definition: fp_shape.h:109
EDA_ITEM is a base class for most all the KiCad significant classes used in schematics and boards.
Definition: eda_item.h:148
PCB_LAYER_ID m_layer
Definition: board_item.h:89
wxString GetSelectMenuText(EDA_UNITS aUnits) const override
Function GetSelectMenuText returns the text to display to be used in the selection clarification cont...
Definition: fp_shape.cpp:121
void SetLocalCoord()
Set relative coordinates from draw coordinates.
Definition: fp_shape.cpp:53
void Move(const wxPoint &aMoveVector) override
Move an edge of the footprint.
Definition: fp_shape.cpp:283
EDA_MSG_ITEM is used EDA_MSG_PANEL as the item type for displaying messages.
Definition: msgpanel.h:54
VIEW.
Definition: view.h:63
wxPoint m_Bezier0_C1
Bezier Control Point 1, relative to footprint origin, orient 0.
Definition: fp_shape.h:155
void SetThirdPoint0(const wxPoint &aPoint)
Definition: fp_shape.h:111
bool IsType(const KICAD_T aScanTypes[]) const override
Function IsType Checks whether the item is one of the listed types.
Definition: fp_shape.h:54
KICAD_T Type() const
Function Type()
Definition: eda_item.h:181