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, SHAPE_T aShape = SHAPE_T::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 
74  void SetArcAngleAndEnd0( double aAngle, bool aCheckNegativeAngle = false );
75 
76  void SetArcGeometry0( const wxPoint& aStart, const wxPoint& aMid, const wxPoint& aEnd );
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 SetBezierC1_0( const wxPoint& aPoint ) { m_bezierC1_0 = aPoint; }
118  const wxPoint& GetBezierC1_0() const { return m_bezierC1_0; }
119 
120  void SetBezierC2_0( const wxPoint& aPoint ) { m_bezierC2_0 = aPoint; }
121  const wxPoint& GetBezierC2_0() const { return m_bezierC2_0; }
122 
123  wxPoint GetCenter0() const;
124  void SetCenter0( const wxPoint& aPt );
125 
126  wxPoint GetArcMid0() const;
127 
133  void SetLocalCoord();
134 
139  void SetDrawCoord();
140 
141  void GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITEM>& aList ) override;
142 
143  wxString GetClass() const override
144  {
145  return wxT( "MGRAPHIC" );
146  }
147 
148  wxString GetParentAsString() const { return m_parent->m_Uuid.AsString(); }
149 
150  wxString GetSelectMenuText( EDA_UNITS aUnits ) const override;
151 
152  BITMAPS GetMenuImage() const override;
153 
154  EDA_ITEM* Clone() const override;
155 
156  double ViewGetLOD( int aLayer, KIGFX::VIEW* aView ) const override;
157 
158 #if defined(DEBUG)
159  void Show( int nestLevel, std::ostream& os ) const override { ShowDummy( os ); }
160 #endif
161 
162 protected:
163  wxPoint m_start0;
164  wxPoint m_end0;
165  wxPoint m_arcCenter0;
166  wxPoint m_bezierC1_0;
167  wxPoint m_bezierC2_0;
168 };
169 
170 #endif // FP_SHAPE_H
EDA_ITEM * m_parent
Linked list: Link (parent struct)
Definition: eda_item.h:479
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:47
void SetArcGeometry0(const wxPoint &aStart, const wxPoint &aMid, const wxPoint &aEnd)
Definition: fp_shape.cpp:194
void SetArcAngleAndEnd0(double aAngle, bool aCheckNegativeAngle=false)
Sets the angle for arcs, and normalizes it within the range 0 - 360 degrees.
Definition: fp_shape.cpp:184
wxString GetParentAsString() const
Definition: fp_shape.h:148
void Flip(const wxPoint &aCentre, bool aFlipLeftRight) override
Flip entity relative to aCentre.
Definition: fp_shape.cpp:202
double ViewGetLOD(int aLayer, KIGFX::VIEW *aView) const override
Return the level of detail (LOD) of the item.
Definition: fp_shape.cpp:362
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
wxPoint m_arcCenter0
Center of arc, relative to footprint origin, orient 0.
Definition: fp_shape.h:165
The base class for create windows for drawing purpose.
static bool ClassOf(const EDA_ITEM *aItem)
Definition: fp_shape.h:49
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_end0
End point or circle edge, relative to footprint origin, orient 0.
Definition: fp_shape.h:164
wxPoint GetCenter0() const
Definition: fp_shape.cpp:141
wxPoint GetArcMid0() const
Definition: fp_shape.cpp:176
FP_SHAPE(FOOTPRINT *parent, SHAPE_T aShape=SHAPE_T::SEGMENT)
Definition: fp_shape.cpp:40
EDA_ITEM * Clone() const override
Create a duplicate of this item with linked list members set to NULL.
Definition: fp_shape.cpp:135
void SetBezierC2_0(const wxPoint &aPoint)
Definition: fp_shape.h:120
SHAPE_T
Definition: eda_shape.h:40
wxString GetClass() const override
Return the class name.
Definition: fp_shape.h:143
void Rotate(const wxPoint &aRotCentre, double aAngle) override
Rotate an edge of the footprint.
Definition: fp_shape.cpp:316
wxPoint m_bezierC2_0
Bezier Control Point 2, relative to footprint origin, orient 0.
Definition: fp_shape.h:167
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:110
virtual bool IsType(const KICAD_T aScanTypes[]) const
Check whether the item is one of the listed types.
Definition: eda_item.h:183
void SetDrawCoord()
Set draw coordinates (absolute values ) from relative coordinates.
Definition: fp_shape.cpp:81
BITMAPS GetMenuImage() const override
Return a pointer to an image to be used in menus.
Definition: fp_shape.cpp:129
void SetStart0(const wxPoint &aPoint)
Definition: fp_shape.h:111
const KIID m_Uuid
Definition: eda_item.h:475
EDA_UNITS
Definition: eda_units.h:38
bool IsParentFlipped() const
Definition: fp_shape.cpp:262
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:269
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:100
PCB_LAYER_ID m_layer
Definition: board_item.h:316
void SetBezierC1_0(const wxPoint &aPoint)
Definition: fp_shape.h:117
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:121
const wxPoint & GetBezierC2_0() const
Definition: fp_shape.h:121
void SetLocalCoord()
Set relative coordinates from draw coordinates.
Definition: fp_shape.cpp:52
void Move(const wxPoint &aMoveVector) override
Move an edge of the footprint.
Definition: fp_shape.cpp:328
EDA_MSG_PANEL items for displaying messages.
Definition: msgpanel.h:53
Hold a (potentially large) number of VIEW_ITEMs and renders them on a graphics device provided by the...
Definition: view.h:68
wxPoint m_start0
Start point or circle center, relative to footprint origin, orient 0.
Definition: fp_shape.h:163
void SetCenter0(const wxPoint &aPt)
Definition: fp_shape.cpp:158
const wxPoint & GetBezierC1_0() const
Definition: fp_shape.h:118
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:113
wxPoint m_bezierC1_0
Bezier Control Point 1, relative to footprint origin, orient 0.
Definition: fp_shape.h:166