KiCad PCB EDA Suite
Loading...
Searching...
No Matches
pcb_point.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) 2004 Jean-Pierre Charras, jp.charras at wanadoo.fr
5 * Copyright The 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
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
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, see <https://www.gnu.org/licenses/>.
19 */
20
21#pragma once
22
23#include <board_item.h>
24
25
38class PCB_POINT : public BOARD_ITEM
39{
40public:
41
42 PCB_POINT( BOARD_ITEM* aParent );
43
47 PCB_POINT( BOARD_ITEM* aParent, const VECTOR2I& aPos, const int aSize);
48
49 static inline bool ClassOf( const EDA_ITEM* aItem )
50 {
51 return aItem && PCB_POINT_T == aItem->Type();
52 }
53
55 {
56 bool operator()( const PCB_POINT* a, const PCB_POINT* b ) const;
57 };
58
59 void SetPosition( const VECTOR2I& aPos ) override;
60 VECTOR2I GetPosition() const override { return m_pos; }
62
63 void SetParent( EDA_ITEM* aParent ) override;
64
66 void OnFootprintTransformed() override;
67
68 void SetSize( const int aSize ) { m_size = aSize; }
69 int GetSize() const { return m_size; }
70
71 void Move( const VECTOR2I& aMoveVector ) override { SetPosition( GetPosition() + aMoveVector ); }
72
73 double ViewGetLOD( int aLayer, const KIGFX::VIEW* aView ) const override;
74 std::vector<int> ViewGetLayers() const override;
75
76 void Rotate( const VECTOR2I& aRotCentre, const EDA_ANGLE& aAngle ) override;
77
78 void Flip( const VECTOR2I& aCentre, FLIP_DIRECTION aFlipDirection ) override;
79
80 wxString GetClass() const override
81 {
82 return wxT( "PCB_POINT" );
83 }
84
85 bool HitTest( const VECTOR2I& aPosition, int aAccuracy = 0 ) const override;
86 bool HitTest( const BOX2I& aRect, bool aContained, int aAccuracy = 0 ) const override;
87
88 // Virtual function
89 const BOX2I GetBoundingBox() const override;
90
91 std::shared_ptr<SHAPE> GetEffectiveShape( PCB_LAYER_ID aLayer = UNDEFINED_LAYER,
93 DRC_CONSTRAINT_T aUsage = NULL_CONSTRAINT ) const override;
94
95 wxString GetItemDescription( UNITS_PROVIDER* aUnitsProvider, bool aFull ) const override;
96
97 BITMAPS GetMenuImage() const override;
98
99 EDA_ITEM* Clone() const override;
100
101 void CopyFrom( const BOARD_ITEM* aOther ) override;
102
103 void Serialize( google::protobuf::Any& aContainer ) const override;
104 bool Deserialize( const google::protobuf::Any& aContainer ) override;
105
106 void GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITEM>& aList ) override;
107
120 void TransformShapeToPolygon( SHAPE_POLY_SET& aBuffer, PCB_LAYER_ID aLayer, int aClearance,
121 int aError, ERROR_LOC aErrorLoc,
122 bool ignoreLineWidth = false ) const override;
123
124 double Similarity( const BOARD_ITEM& aBoardItem ) const override;
125
126 bool operator==( const PCB_POINT& aOther ) const;
127 bool operator==( const BOARD_ITEM& aBoardItem ) const override;
128
129#if defined( DEBUG )
130 void Show( int nestLevel, std::ostream& os ) const override { ShowDummy( os ); }
131#endif
132
133protected:
134 virtual void swapData( BOARD_ITEM* aImage ) override;
135
136private:
138 void recomputePosition();
139
140 // Position in parent footprint's library frame (or board space if no parent footprint)
142 // Cached board-space position, refreshed when the parent footprint transform changes
144 // Visual size of the point in board space
146};
ERROR_LOC
When approximating an arc or circle, should the error be placed on the outside or inside of the curve...
BITMAPS
A list of all bitmap identifiers.
BOX2< VECTOR2I > BOX2I
Definition box2.h:927
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
Definition board_item.h:84
BOARD_ITEM(BOARD_ITEM *aParent, KICAD_T idtype, PCB_LAYER_ID aLayer=F_Cu)
Definition board_item.h:86
The base class for create windows for drawing purpose.
A base class for most all the KiCad significant classes used in schematics and boards.
Definition eda_item.h:98
KICAD_T Type() const
Returns the type of object.
Definition eda_item.h:110
EDA_ITEM(EDA_ITEM *parent, KICAD_T idType, bool isSCH_ITEM=false, bool isBOARD_ITEM=false)
Definition eda_item.cpp:84
Hold a (potentially large) number of VIEW_ITEMs and renders them on a graphics device provided by the...
Definition view.h:63
A PCB_POINT is a 0-dimensional point that is used to mark a position on a PCB, or more usually a foot...
Definition pcb_point.h:39
void TransformShapeToPolygon(SHAPE_POLY_SET &aBuffer, PCB_LAYER_ID aLayer, int aClearance, int aError, ERROR_LOC aErrorLoc, bool ignoreLineWidth=false) const override
Convert the shape to a closed polygon.
PCB_POINT(BOARD_ITEM *aParent)
Definition pcb_point.cpp:47
wxString GetClass() const override
Return the class name.
Definition pcb_point.h:80
std::shared_ptr< SHAPE > GetEffectiveShape(PCB_LAYER_ID aLayer=UNDEFINED_LAYER, FLASHING aFlash=FLASHING::DEFAULT, DRC_CONSTRAINT_T aUsage=NULL_CONSTRAINT) const override
Some pad shapes can be complex (rounded/chamfered rectangle), even without considering custom shapes.
EDA_ITEM * Clone() const override
Create a duplicate of this item with linked list members set to NULL.
void Flip(const VECTOR2I &aCentre, FLIP_DIRECTION aFlipDirection) override
Flip this object, i.e.
VECTOR2I m_pos
Definition pcb_point.h:143
static bool ClassOf(const EDA_ITEM *aItem)
Definition pcb_point.h:49
std::vector< int > ViewGetLayers() const override
Return the all the layers within the VIEW the object is painted on.
bool operator==(const PCB_POINT &aOther) const
int GetSize() const
Definition pcb_point.h:69
void recomputePosition()
Recompute the cached board position from the library position and parent transform.
Definition pcb_point.cpp:67
void SetParent(EDA_ITEM *aParent) override
Definition pcb_point.cpp:87
double ViewGetLOD(int aLayer, const KIGFX::VIEW *aView) const override
Return the level of detail (LOD) of the item.
void SetPosition(const VECTOR2I &aPos) override
Definition pcb_point.cpp:76
bool HitTest(const VECTOR2I &aPosition, int aAccuracy=0) const override
Test if aPosition is inside or on the boundary of this item.
wxString GetItemDescription(UNITS_PROVIDER *aUnitsProvider, bool aFull) const override
Return a user-visible description string of this item.
void Serialize(google::protobuf::Any &aContainer) const override
Serializes this object to the given Any message.
BITMAPS GetMenuImage() const override
Return a pointer to an image to be used in menus.
void Rotate(const VECTOR2I &aRotCentre, const EDA_ANGLE &aAngle) override
Rotate this object.
virtual void swapData(BOARD_ITEM *aImage) override
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.
void SetSize(const int aSize)
Definition pcb_point.h:68
void OnFootprintTransformed() override
Refresh the cached board position after the parent footprint's transform changed.
Definition pcb_point.cpp:94
double Similarity(const BOARD_ITEM &aBoardItem) const override
Return a measure of how likely the other object is to represent the same object.
void CopyFrom(const BOARD_ITEM *aOther) override
void Move(const VECTOR2I &aMoveVector) override
Move this object.
Definition pcb_point.h:71
VECTOR2I m_libPos
Definition pcb_point.h:141
bool Deserialize(const google::protobuf::Any &aContainer) override
Deserializes the given protobuf message into this object.
const BOX2I GetBoundingBox() const override
Return the orthogonal bounding box of this object for display purposes.
VECTOR2I GetPosition() const override
Definition pcb_point.h:60
VECTOR2I GetLibraryPosition() const
Definition pcb_point.h:61
Represent a set of closed polygons.
DRC_CONSTRAINT_T
Definition drc_rule.h:49
@ NULL_CONSTRAINT
Definition drc_rule.h:50
FLASHING
Enum used during connectivity building to ensure we do not query connectivity while building the data...
Definition layer_ids.h:180
@ DEFAULT
Flashing follows connectivity.
Definition layer_ids.h:181
PCB_LAYER_ID
A quick note on layer IDs:
Definition layer_ids.h:56
@ UNDEFINED_LAYER
Definition layer_ids.h:57
FLIP_DIRECTION
Definition mirror.h:23
bool operator()(const PCB_POINT *a, const PCB_POINT *b) const
@ PCB_POINT_T
class PCB_POINT, a 0-dimensional point
Definition typeinfo.h:105
VECTOR2< int32_t > VECTOR2I
Definition vector2d.h:683