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:
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 
76  void SetAngle( double aAngle, bool aUpdateEnd = true ) override;
77 
83  void Move( const wxPoint& aMoveVector ) override;
84 
91  void Mirror( const wxPoint& aCentre, bool aMirrorAroundXAxis );
92 
98  void Rotate( const wxPoint& aRotCentre, double aAngle ) override;
99 
107  void Flip( const wxPoint& aCentre, bool aFlipLeftRight ) override;
108 
109  bool IsParentFlipped() const;
110 
111  void SetStart0( const wxPoint& aPoint ) { m_Start0 = aPoint; }
112  const wxPoint& GetStart0() const { return m_Start0; }
113 
114  void SetEnd0( const wxPoint& aPoint ) { m_End0 = aPoint; }
115  const wxPoint& GetEnd0() const { return m_End0; }
116 
117  void SetThirdPoint0( const wxPoint& aPoint ){ m_ThirdPoint0 = aPoint; }
118  const wxPoint& GetThirdPoint0() const { return m_ThirdPoint0; }
119 
120  void SetBezier0_C1( const wxPoint& aPoint ) { m_Bezier0_C1 = aPoint; }
121  const wxPoint& GetBezier0_C1() const { return m_Bezier0_C1; }
122 
123  void SetBezier0_C2( const wxPoint& aPoint ) { m_Bezier0_C2 = aPoint; }
124  const wxPoint& GetBezier0_C2() const { return m_Bezier0_C2; }
125 
131  void SetLocalCoord();
132 
137  void SetDrawCoord();
138 
139  void GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITEM>& aList ) override;
140 
141  wxString GetClass() const override
142  {
143  return wxT( "MGRAPHIC" );
144  }
145 
146  wxString GetParentAsString() const { return m_parent->m_Uuid.AsString(); }
147 
148  wxString GetSelectMenuText( EDA_UNITS aUnits ) const override;
149 
150  BITMAPS GetMenuImage() const override;
151 
152  EDA_ITEM* Clone() const override;
153 
154  double ViewGetLOD( int aLayer, KIGFX::VIEW* aView ) const override;
155 
156 #if defined(DEBUG)
157  void Show( int nestLevel, std::ostream& os ) const override { ShowDummy( os ); }
158 #endif
159 
160  wxPoint m_Start0;
161  wxPoint m_End0;
162  wxPoint m_ThirdPoint0;
163  wxPoint m_Bezier0_C1;
164  wxPoint m_Bezier0_C2;
165 };
166 
167 #endif // FP_SHAPE_H
EDA_ITEM * m_parent
Linked list: Link (parent struct)
Definition: eda_item.h:529
An abstract class from which implementation specific LINE_READERs may be derived to read single lines...
Definition: richio.h:80
void SetEnd0(const wxPoint &aPoint)
Definition: fp_shape.h:114
~FP_SHAPE()
Definition: fp_shape.cpp:49
wxString GetParentAsString() const
Definition: fp_shape.h:146
void Flip(const wxPoint &aCentre, bool aFlipLeftRight) override
Flip entity relative to aCentre.
Definition: fp_shape.cpp:158
void SetBezier0_C1(const wxPoint &aPoint)
Definition: fp_shape.h:120
double ViewGetLOD(int aLayer, KIGFX::VIEW *aView) const override
Return the level of detail (LOD) of the item.
Definition: fp_shape.cpp:316
const wxPoint & GetStart0() const
Definition: fp_shape.h:112
wxString AsString() const
Definition: kiid.cpp:218
class FP_SHAPE, a footprint edge
Definition: typeinfo.h:93
PCB_SHAPE_TYPE
The set of shapes for PCB graphics and tracks and footprint graphics in the .m_Shape member.
Definition: board_item.h:48
The base class for create windows for drawing purpose.
static bool ClassOf(const EDA_ITEM *aItem)
Definition: fp_shape.h:49
FP_SHAPE(FOOTPRINT *parent, PCB_SHAPE_TYPE aShape=PCB_SHAPE_TYPE::SEGMENT)
Definition: fp_shape.cpp:40
void SetBezier0_C2(const wxPoint &aPoint)
Definition: fp_shape.h:123
search types array terminator (End Of Types)
Definition: typeinfo.h:81
KICAD_T
The set of class identification values stored in EDA_ITEM::m_structType.
Definition: typeinfo.h:77
wxPoint m_ThirdPoint0
End point for an arc.
Definition: fp_shape.h:162
EDA_ITEM * Clone() const override
Create a duplicate of this item with linked list members set to NULL.
Definition: fp_shape.cpp:136
const wxPoint & GetThirdPoint0() const
Definition: fp_shape.h:118
wxString GetClass() const override
Return the class name.
Definition: fp_shape.h:141
void Rotate(const wxPoint &aRotCentre, double aAngle) override
Rotate an edge of the footprint.
Definition: fp_shape.cpp:277
void SetAngle(double aAngle, bool aUpdateEnd=true) override
Sets the angle for arcs, and normalizes it within the range 0 - 360 degrees.
Definition: fp_shape.cpp:142
void GetMsgPanelInfo(EDA_DRAW_FRAME *aFrame, std::vector< MSG_PANEL_ITEM > &aList) override
Populate aList of MSG_PANEL_ITEM objects with it's internal state for display purposes.
Definition: fp_shape.cpp:111
wxPoint m_End0
End point, relative to footprint origin, orient 0.
Definition: fp_shape.h:161
wxPoint m_Start0
Start point or center, relative to footprint origin, orient 0.
Definition: fp_shape.h:160
virtual bool IsType(const KICAD_T aScanTypes[]) const
Check whether the item is one of the listed types.
Definition: eda_item.h:233
void SetDrawCoord()
Set draw coordinates (absolute values ) from relative coordinates.
Definition: fp_shape.cpp:82
BITMAPS GetMenuImage() const override
Return a pointer to an image to be used in menus.
Definition: fp_shape.cpp:130
void SetStart0(const wxPoint &aPoint)
Definition: fp_shape.h:111
const KIID m_Uuid
Definition: eda_item.h:525
wxPoint m_Bezier0_C2
Bezier Control Point 2, relative to footprint origin, orient 0.
Definition: fp_shape.h:164
EDA_UNITS
Definition: eda_units.h:38
bool IsParentFlipped() const
Definition: fp_shape.cpp:217
const wxPoint & GetBezier0_C2() const
Definition: fp_shape.h:124
const wxPoint & GetBezier0_C1() const
Definition: fp_shape.h:121
BITMAPS
A list of all bitmap identifiers.
Definition: bitmaps_list.h:32
void Mirror(const wxPoint &aCentre, bool aMirrorAroundXAxis)
Mirror an edge of the footprint.
Definition: fp_shape.cpp:224
usual segment : line with rounded ends
const wxPoint & GetEnd0() const
Definition: fp_shape.h:115
A base class for most all the KiCad significant classes used in schematics and boards.
Definition: eda_item.h:150
PCB_LAYER_ID m_layer
Definition: board_item.h:363
wxString GetSelectMenuText(EDA_UNITS aUnits) const override
Return the text to display to be used in the selection clarification context menu when multiple items...
Definition: fp_shape.cpp:122
void SetLocalCoord()
Set relative coordinates from draw coordinates.
Definition: fp_shape.cpp:54
void Move(const wxPoint &aMoveVector) override
Move an edge of the footprint.
Definition: fp_shape.cpp:289
EDA_MSG_ITEM is used EDA_MSG_PANEL as the item type for displaying messages.
Definition: msgpanel.h:54
Hold a (potentially large) number of VIEW_ITEMs and renders them on a graphics device provided by the...
Definition: view.h:67
wxPoint m_Bezier0_C1
Bezier Control Point 1, relative to footprint origin, orient 0.
Definition: fp_shape.h:163
void SetThirdPoint0(const wxPoint &aPoint)
Definition: fp_shape.h:117
bool IsType(const KICAD_T aScanTypes[]) const override
Check whether the item is one of the listed types.
Definition: fp_shape.h:54
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:163