KiCad PCB EDA Suite
Loading...
Searching...
No Matches
pcb_marker.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) 2009-2018 Jean-Pierre Charras, [email protected]
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
24#include <board_item.h>
25#include <pcb_shape.h>
26#include <rc_item.h>
27#include <marker_base.h>
28
29class DRC_ITEM;
30class MSG_PANEL_ITEM;
31
32
33namespace kiapi::board
34{
35class DrcMarker;
36}
37
38class PCB_MARKER : public BOARD_ITEM, public MARKER_BASE
39{
40public:
41 PCB_MARKER( std::shared_ptr<DRC_ITEM> aItem, const VECTOR2I& aPos, int aLayer = F_Cu );
42
44
45 static inline bool ClassOf( const EDA_ITEM* aItem )
46 {
47 return aItem && PCB_MARKER_T == aItem->Type();
48 }
49
50 const KIID GetUUID() const override { return m_Uuid; }
51
52 void Serialize( google::protobuf::Any& aContainer ) const override;
53 bool Deserialize( const google::protobuf::Any& aContainer ) override;
54
55 static PCB_MARKER* FromProto( const kiapi::board::DrcMarker& aMsg );
56
57 static void ToProto( kiapi::board::DrcMarker& aMsg, const PCB_MARKER& aMarker );
58
59 static PCB_MARKER* FromLegacyString( const wxString& aData );
60
61 void Move( const VECTOR2I& aMoveVector ) override
62 {
63 m_Pos += aMoveVector;
64 }
65
66 void Rotate( const VECTOR2I& aRotCentre, const EDA_ANGLE& aAngle ) override;
67
68 void Flip( const VECTOR2I& aCentre, FLIP_DIRECTION aFlipDirection ) override;
69
70 VECTOR2I GetPosition() const override { return m_Pos; }
71 void SetPosition( const VECTOR2I& aPos ) override { m_Pos = aPos; }
72
73 VECTOR2I GetCenter() const override
74 {
75 return GetPosition();
76 }
77
78 bool HitTest( const VECTOR2I& aPosition, int aAccuracy = 0 ) const override
79 {
81 return false;
82 else
83 return HitTestMarker( aPosition, aAccuracy );
84 }
85
86 bool HitTest( const BOX2I& aRect, bool aContained, int aAccuracy = 0 ) const override
87 {
89 return false;
90
91 return HitTestMarker( aRect, aContained, aAccuracy );
92 }
93
94 bool HitTest( const SHAPE_LINE_CHAIN& aPoly, bool aContained ) const override
95 {
97 return false;
98
99 return HitTestMarker( aPoly, aContained );
100 }
101
102 EDA_ITEM* Clone() const override;
103
105
106 std::shared_ptr<SHAPE> GetEffectiveShape( PCB_LAYER_ID aLayer = UNDEFINED_LAYER,
108 DRC_CONSTRAINT_T aUsage = NULL_CONSTRAINT ) const override;
109
110 double GetCoverageArea( int aTextMargin ) const override;
111
112 void TransformShapeToPolygon( SHAPE_POLY_SET& aBuffer, PCB_LAYER_ID aLayer, int aClearance,
113 int aError, ERROR_LOC aErrorLoc, bool ignoreLineWidth ) const override;
114
115
116 void GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITEM>& aList ) override;
117
118 bool Matches( const EDA_SEARCH_DATA& aSearchData, void* aAuxData ) const override
119 {
120 return BOARD_ITEM::Matches( m_rcItem->GetErrorMessage( true ), aSearchData );
121 }
122
123 wxString GetItemDescription( UNITS_PROVIDER* aUnitsProvider, bool aFull ) const override;
124
125 BITMAPS GetMenuImage() const override;
126
127 void SetZoom( double aZoomFactor ) const;
128
129 const BOX2I ViewBBox() const override;
130
131 const BOX2I GetBoundingBox() const override;
132
133 std::vector<int> ViewGetLayers() const override;
134
135 SEVERITY GetSeverity() const override;
136
137 double Similarity( const BOARD_ITEM& aBoardItem ) const override
138 {
139 return 0.0;
140 }
141
142 bool operator==( const BOARD_ITEM& aBoardItem ) const override
143 {
144 return false;
145 }
146
147#if defined(DEBUG)
148 void Show( int nestLevel, std::ostream& os ) const override { ShowDummy( os ); }
149#endif
150
154 virtual wxString GetClass() const override
155 {
156 return wxT( "PCB_MARKER" );
157 }
158
159 std::vector<PCB_SHAPE> GetErrorLegendShapes() const;
160
161 void SetPath( const std::vector<PCB_SHAPE>& aShapes, const VECTOR2I& aStart, const VECTOR2I& aEnd )
162 {
163 m_pathShapes = aShapes;
164 m_pathStart = aStart;
165 m_pathEnd = aEnd;
166 }
167
168 const std::vector<PCB_SHAPE>& GetPath() const { return m_pathShapes; }
169
170protected:
171 void swapData( BOARD_ITEM* aImage ) override;
172
173 KIGFX::COLOR4D getColor() const override;
174
175protected:
176 std::vector<PCB_SHAPE> m_pathShapes; // Shown on LAYER_DRC_SHAPES
180};
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:917
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
Definition board_item.h:99
BOARD_ITEM(BOARD_ITEM *aParent, KICAD_T idtype, PCB_LAYER_ID aLayer=F_Cu)
Definition board_item.h:101
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
const KIID m_Uuid
Definition eda_item.h:599
KICAD_T Type() const
Returns the type of object.
Definition eda_item.h:110
virtual bool Matches(const EDA_SEARCH_DATA &aSearchData, void *aAuxData) const
Compare the item against the search criteria in aSearchData.
Definition eda_item.h:484
EDA_ITEM(EDA_ITEM *parent, KICAD_T idType, bool isSCH_ITEM=false, bool isBOARD_ITEM=false)
Definition eda_item.cpp:84
A color representation with 4 components: red, green, blue, alpha.
Definition color4d.h:101
Definition kiid.h:46
bool HitTestMarker(const VECTOR2I &aHitPosition, int aAccuracy) const
Test if the given VECTOR2I is within the bounds of this object.
VECTOR2I m_Pos
Position of the marker.
std::shared_ptr< RC_ITEM > m_rcItem
enum MARKER_T GetMarkerType() const
Definition marker_base.h:86
MARKER_BASE(int aScalingFactor, std::shared_ptr< RC_ITEM > aItem, MARKER_T aType=MARKER_UNSPEC)
EDA_MSG_PANEL items for displaying messages.
Definition msgpanel.h:50
const KIID GetUUID() const override
Definition pcb_marker.h:50
void SetZoom(double aZoomFactor) const
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.
VECTOR2I m_pathEnd
Definition pcb_marker.h:178
void TransformShapeToPolygon(SHAPE_POLY_SET &aBuffer, PCB_LAYER_ID aLayer, int aClearance, int aError, ERROR_LOC aErrorLoc, bool ignoreLineWidth) const override
Convert the item shape to a closed polygon.
PCB_MARKER(std::shared_ptr< DRC_ITEM > aItem, const VECTOR2I &aPos, int aLayer=F_Cu)
VECTOR2I m_pathStart
Definition pcb_marker.h:177
bool operator==(const BOARD_ITEM &aBoardItem) const override
Definition pcb_marker.h:142
std::vector< PCB_SHAPE > m_pathShapes
Definition pcb_marker.h:176
std::vector< PCB_SHAPE > GetErrorLegendShapes() const
const std::vector< PCB_SHAPE > & GetPath() const
Definition pcb_marker.h:168
BITMAPS GetMenuImage() const override
Return a pointer to an image to be used in menus.
void Move(const VECTOR2I &aMoveVector) override
Move this object.
Definition pcb_marker.h:61
const BOX2I ViewBBox() const override
Return the bounding box of the item covering all its layers.
virtual wxString GetClass() const override
Get class name.
Definition pcb_marker.h:154
std::vector< int > ViewGetLayers() const override
Return the all the layers within the VIEW the object is painted on.
const BOX2I GetBoundingBox() const override
Return the orthogonal bounding box of this object for display purposes.
SEVERITY GetSeverity() const override
void Serialize(google::protobuf::Any &aContainer) const override
Serializes this object to the given Any message.
void Flip(const VECTOR2I &aCentre, FLIP_DIRECTION aFlipDirection) override
Flip this object, i.e.
bool HitTest(const BOX2I &aRect, bool aContained, int aAccuracy=0) const override
Test if aRect intersects this item.
Definition pcb_marker.h:86
static PCB_MARKER * FromLegacyString(const wxString &aData)
static void ToProto(kiapi::board::DrcMarker &aMsg, const PCB_MARKER &aMarker)
VECTOR2I GetCenter() const override
This defaults to the center of the bounding box if not overridden.
Definition pcb_marker.h:73
GAL_LAYER_ID GetColorLayer() const
VECTOR2I GetPosition() const override
Definition pcb_marker.h:70
bool Deserialize(const google::protobuf::Any &aContainer) override
Deserializes the given protobuf message into this object.
KIGFX::COLOR4D getColor() const override
static bool ClassOf(const EDA_ITEM *aItem)
Definition pcb_marker.h:45
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.
double Similarity(const BOARD_ITEM &aBoardItem) const override
Return a measure of how likely the other object is to represent the same object.
Definition pcb_marker.h:137
bool Matches(const EDA_SEARCH_DATA &aSearchData, void *aAuxData) const override
Compare the item against the search criteria in aSearchData.
Definition pcb_marker.h:118
wxString GetItemDescription(UNITS_PROVIDER *aUnitsProvider, bool aFull) const override
Return a user-visible description string of this item.
void SetPath(const std::vector< PCB_SHAPE > &aShapes, const VECTOR2I &aStart, const VECTOR2I &aEnd)
Definition pcb_marker.h:161
EDA_ITEM * Clone() const override
Create a duplicate of this item with linked list members set to NULL.
int m_pathLength
Definition pcb_marker.h:179
double GetCoverageArea(int aTextMargin) const override
Return the board area this item covers, used to rank candidates under the cursor so a click on a smal...
bool HitTest(const VECTOR2I &aPosition, int aAccuracy=0) const override
Test if aPosition is inside or on the boundary of this item.
Definition pcb_marker.h:78
static PCB_MARKER * FromProto(const kiapi::board::DrcMarker &aMsg)
void swapData(BOARD_ITEM *aImage) override
void Rotate(const VECTOR2I &aRotCentre, const EDA_ANGLE &aAngle) override
Rotate this object.
bool HitTest(const SHAPE_LINE_CHAIN &aPoly, bool aContained) const override
Test if aPoly intersects this item.
Definition pcb_marker.h:94
void SetPosition(const VECTOR2I &aPos) override
Definition pcb_marker.h:71
Represent a polyline containing arcs as well as line segments: A chain of connected line and/or arc s...
Represent a set of closed polygons.
@ NULL_CONSTRAINT
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
GAL_LAYER_ID
GAL layers are "virtual" layers, i.e.
Definition layer_ids.h:224
PCB_LAYER_ID
A quick note on layer IDs:
Definition layer_ids.h:56
@ UNDEFINED_LAYER
Definition layer_ids.h:57
@ F_Cu
Definition layer_ids.h:60
FLIP_DIRECTION
Definition mirror.h:26
SEVERITY
@ PCB_MARKER_T
class PCB_MARKER, a marker used to show something
Definition typeinfo.h:91
VECTOR2< int32_t > VECTOR2I
Definition vector2d.h:708