KiCad PCB EDA Suite
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
5  * Copyright (C) 1992-2021 KiCad Developers, see AUTHORS.txt for contributors.
6  *
7  * This program is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation; either version 2
10  * of the License, or (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, you may find one here:
19  *
20  * or you may search the website for the version 2 license,
21  * or you may write to the Free Software Foundation, Inc.,
22  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
23  */
25 #ifndef PCB_SHAPE_H
26 #define PCB_SHAPE_H
28 #include <board_item.h>
29 #include <eda_shape.h>
32 class LINE_READER;
33 class EDA_DRAW_FRAME;
34 class FOOTPRINT;
35 class MSG_PANEL_ITEM;
38 class PCB_SHAPE : public BOARD_ITEM, public EDA_SHAPE
39 {
40 public:
41  PCB_SHAPE( BOARD_ITEM* aParent, KICAD_T idtype, SHAPE_T shapetype );
43  PCB_SHAPE( BOARD_ITEM* aParent = NULL, SHAPE_T shapetype = SHAPE_T::SEGMENT );
45  // Do not create a copy constructor & operator=.
46  // The ones generated by the compiler are adequate.
48  ~PCB_SHAPE();
50  static inline bool ClassOf( const EDA_ITEM* aItem )
51  {
52  return aItem && PCB_SHAPE_T == aItem->Type();
53  }
55  wxString GetClass() const override
56  {
57  return wxT( "PCB_SHAPE" );
58  }
60  bool IsType( const KICAD_T aScanTypes[] ) const override
61  {
62  if( BOARD_ITEM::IsType( aScanTypes ) )
63  return true;
65  for( const KICAD_T* p = aScanTypes; *p != EOT; ++p )
66  {
67  if( *p == PCB_LOCATE_GRAPHIC_T )
68  return true;
69  else if( *p == PCB_LOCATE_BOARD_EDGE_T )
70  return m_layer == Edge_Cuts;
71  }
73  return false;
74  }
76  void SetPosition( const wxPoint& aPos ) override { setPosition( aPos ); }
77  wxPoint GetPosition() const override { return getPosition(); }
79  wxPoint GetCenter() const override { return getCenter(); }
85  const wxPoint GetFocusPosition() const override;
97  std::shared_ptr<SHAPE> GetEffectiveShape( PCB_LAYER_ID aLayer = UNDEFINED_LAYER,
98  FLASHING aFlash = FLASHING::DEFAULT ) const override;
100  void GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITEM>& aList ) override;
102  const EDA_RECT GetBoundingBox() const override { return getBoundingBox(); }
104  bool HitTest( const wxPoint& aPosition, int aAccuracy = 0 ) const override
105  {
106  return hitTest( aPosition, aAccuracy );
107  }
109  bool HitTest( const EDA_RECT& aRect, bool aContained, int aAccuracy = 0 ) const override
110  {
111  return hitTest( aRect, aContained, aAccuracy );
112  }
114  virtual void Move( const wxPoint& aMoveVector ) override;
116  virtual void Rotate( const wxPoint& aRotCentre, double aAngle ) override;
118  virtual void Flip( const wxPoint& aCentre, bool aFlipLeftRight ) override;
120  void Scale( double aScale );
135  PCB_LAYER_ID aLayer, int aClearanceValue,
136  int aError, ERROR_LOC aErrorLoc,
137  bool ignoreLineWidth = false ) const override;
139  virtual wxString GetSelectMenuText( EDA_UNITS aUnits ) const override;
141  virtual BITMAPS GetMenuImage() const override;
143  virtual EDA_ITEM* Clone() const override;
145  virtual const BOX2I ViewBBox() const override;
147  virtual void SwapData( BOARD_ITEM* aImage ) override;
150  {
151  bool operator()( const BOARD_ITEM* aFirst, const BOARD_ITEM* aSecond ) const;
152  };
154 #if defined(DEBUG)
155  void Show( int nestLevel, std::ostream& os ) const override { ShowDummy( os ); }
156 #endif
158 protected:
159  double getParentOrientation() const override;
160  wxPoint getParentPosition() const override;
161 };
163 #endif // PCB_SHAPE_H
An abstract class from which implementation specific LINE_READERs may be derived to read single lines...
Definition: richio.h:80
virtual void SwapData(BOARD_ITEM *aImage) override
Swap data between aItem and aImage.
Definition: pcb_shape.cpp:198
wxPoint getCenter() const
Definition: eda_shape.cpp:393
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
Definition: board_item.h:49
void Scale(double aScale)
Definition: pcb_shape.cpp:103
virtual EDA_ITEM * Clone() const override
Create a duplicate of this item with linked list members set to NULL.
Definition: pcb_shape.cpp:175
bool hitTest(const wxPoint &aPosition, int aAccuracy=0) const
Definition: eda_shape.cpp:695
virtual BITMAPS GetMenuImage() const override
Return a pointer to an image to be used in menus.
Definition: pcb_shape.cpp:169
bool operator()(const BOARD_ITEM *aFirst, const BOARD_ITEM *aSecond) const
Definition: pcb_shape.cpp:214
virtual const BOX2I ViewBBox() const override
Return the bounding box of the item covering all its layers.
Definition: pcb_shape.cpp:181
The base class for create windows for drawing purpose.
virtual void Rotate(const wxPoint &aRotCentre, double aAngle) override
Rotate this object.
Definition: pcb_shape.cpp:109
PCB_SHAPE(BOARD_ITEM *aParent, KICAD_T idtype, SHAPE_T shapetype)
Definition: pcb_shape.cpp:36
search types array terminator (End Of Types)
Definition: typeinfo.h:81
The set of class identification values stored in EDA_ITEM::m_structType.
Definition: typeinfo.h:77
wxPoint getParentPosition() const override
Definition: pcb_shape.cpp:141
When approximating an arc or circle, should the error be placed on the outside or inside of the curve...
bool HitTest(const wxPoint &aPosition, int aAccuracy=0) const override
Test if aPosition is inside or on the boundary of this item.
Definition: pcb_shape.h:104
virtual void Move(const wxPoint &aMoveVector) override
Move this object.
Definition: pcb_shape.cpp:97
Represent a set of closed polygons.
Definition: eda_shape.h:40
wxPoint GetCenter() const override
This defaults to the center of the bounding box if not overridden.
Definition: pcb_shape.h:79
virtual bool IsType(const KICAD_T aScanTypes[]) const
Check whether the item is one of the listed types.
Definition: eda_item.h:182
void SetPosition(const wxPoint &aPos) override
Definition: pcb_shape.h:76
bool HitTest(const EDA_RECT &aRect, bool aContained, int aAccuracy=0) const override
Test if aRect intersects this item.
Definition: pcb_shape.h:109
void setPosition(const wxPoint &aPos)
Definition: eda_shape.cpp:89
std::shared_ptr< SHAPE > GetEffectiveShape(PCB_LAYER_ID aLayer=UNDEFINED_LAYER, FLASHING aFlash=FLASHING::DEFAULT) const override
Make a set of SHAPE objects representing the PCB_SHAPE.
Definition: pcb_shape.cpp:192
Enum used during connectivity building to ensure we do not query connectivity while building the data...
Definition: layer_ids.h:153
virtual 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: pcb_shape.cpp:163
Definition: eda_units.h:38
wxPoint GetPosition() const override
Definition: pcb_shape.h:77
const EDA_RECT getBoundingBox() const
Definition: eda_shape.cpp:634
bool IsType(const KICAD_T aScanTypes[]) const override
Check whether the item is one of the listed types.
Definition: pcb_shape.h:60
wxString GetClass() const override
Return the class name.
Definition: pcb_shape.h:55
A list of all bitmap identifiers.
Definition: bitmaps_list.h:32
FOOTPRINT * GetParentFootprint() const
Return the parent footprint or NULL if PCB_SHAPE does not belong to a footprint.
Definition: pcb_shape.cpp:123
A quick note on layer IDs:
Definition: layer_ids.h:65
const EDA_RECT GetBoundingBox() const override
Return the orthogonal bounding box of this object for display purposes.
Definition: pcb_shape.h:102
Handle the component boundary box.
Definition: eda_rect.h:42
const wxPoint GetFocusPosition() const override
Allows items to return their visual center rather than their anchor.
Definition: pcb_shape.cpp:55
A base class for most all the KiCad significant classes used in schematics and boards.
Definition: eda_item.h:99
PCB_LAYER_ID m_layer
Definition: board_item.h:313
static bool ClassOf(const EDA_ITEM *aItem)
Definition: pcb_shape.h:50
wxPoint getPosition() const
Definition: eda_shape.cpp:95
virtual void Flip(const wxPoint &aCentre, bool aFlipLeftRight) override
Flip this object, i.e.
Definition: pcb_shape.cpp:115
EDA_MSG_PANEL items for displaying messages.
Definition: msgpanel.h:53
void TransformShapeWithClearanceToPolygon(SHAPE_POLY_SET &aCornerBuffer, PCB_LAYER_ID aLayer, int aClearanceValue, int aError, ERROR_LOC aErrorLoc, bool ignoreLineWidth=false) const override
Convert the shape to a closed polygon.
Definition: pcb_shape.cpp:236
class PCB_SHAPE, a segment not on copper layers
Definition: typeinfo.h:90
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: pcb_shape.cpp:150
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:112
double getParentOrientation() const override
Definition: pcb_shape.cpp:132