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<RC_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 static PCB_MARKER* FromLegacyString( const wxString& aData );
57
58 void Move( const VECTOR2I& aMoveVector ) override
59 {
60 m_Pos += aMoveVector;
61 }
62
63 void Rotate( const VECTOR2I& aRotCentre, const EDA_ANGLE& aAngle ) override;
64
65 void Flip( const VECTOR2I& aCentre, FLIP_DIRECTION aFlipDirection ) override;
66
67 VECTOR2I GetPosition() const override { return m_Pos; }
68 void SetPosition( const VECTOR2I& aPos ) override { m_Pos = aPos; }
69
70 VECTOR2I GetCenter() const override
71 {
72 return GetPosition();
73 }
74
75 bool HitTest( const VECTOR2I& aPosition, int aAccuracy = 0 ) const override
76 {
78 return false;
79 else
80 return HitTestMarker( aPosition, aAccuracy );
81 }
82
83 bool HitTest( const BOX2I& aRect, bool aContained, int aAccuracy = 0 ) const override
84 {
86 return false;
87
88 return HitTestMarker( aRect, aContained, aAccuracy );
89 }
90
91 bool HitTest( const SHAPE_LINE_CHAIN& aPoly, bool aContained ) const override
92 {
94 return false;
95
96 return HitTestMarker( aPoly, aContained );
97 }
98
99 EDA_ITEM* Clone() const override;
100
102
103 std::shared_ptr<SHAPE> GetEffectiveShape( PCB_LAYER_ID aLayer = UNDEFINED_LAYER,
105 DRC_CONSTRAINT_T aUsage = NULL_CONSTRAINT ) const override;
106
107 void TransformShapeToPolygon( SHAPE_POLY_SET& aBuffer, PCB_LAYER_ID aLayer, int aClearance,
108 int aError, ERROR_LOC aErrorLoc, bool ignoreLineWidth ) const override;
109
110
111 void GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITEM>& aList ) override;
112
113 bool Matches( const EDA_SEARCH_DATA& aSearchData, void* aAuxData ) const override
114 {
115 return BOARD_ITEM::Matches( m_rcItem->GetErrorMessage( true ), aSearchData );
116 }
117
118 wxString GetItemDescription( UNITS_PROVIDER* aUnitsProvider, bool aFull ) const override;
119
120 BITMAPS GetMenuImage() const override;
121
122 void SetZoom( double aZoomFactor ) const;
123
124 const BOX2I ViewBBox() const override;
125
126 const BOX2I GetBoundingBox() const override;
127
128 std::vector<int> ViewGetLayers() const override;
129
130 SEVERITY GetSeverity() const override;
131
132 double Similarity( const BOARD_ITEM& aBoardItem ) const override
133 {
134 return 0.0;
135 }
136
137 bool operator==( const BOARD_ITEM& aBoardItem ) const override
138 {
139 return false;
140 }
141
142#if defined(DEBUG)
143 void Show( int nestLevel, std::ostream& os ) const override { ShowDummy( os ); }
144#endif
145
149 virtual wxString GetClass() const override
150 {
151 return wxT( "PCB_MARKER" );
152 }
153
154 std::vector<PCB_SHAPE> GetErrorLegendShapes() const;
155
156 void SetPath( const std::vector<PCB_SHAPE>& aShapes, const VECTOR2I& aStart, const VECTOR2I& aEnd )
157 {
158 m_pathShapes = aShapes;
159 m_pathStart = aStart;
160 m_pathEnd = aEnd;
161 }
162
163 const std::vector<PCB_SHAPE>& GetPath() const { return m_pathShapes; }
164
165protected:
166 void swapData( BOARD_ITEM* aImage ) override;
167
168 KIGFX::COLOR4D getColor() const override;
169
170protected:
171 std::vector<PCB_SHAPE> m_pathShapes; // Shown on LAYER_DRC_SHAPES
175};
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
const KIID m_Uuid
Definition eda_item.h:597
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:482
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:87
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:173
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.
VECTOR2I m_pathStart
Definition pcb_marker.h:172
bool operator==(const BOARD_ITEM &aBoardItem) const override
Definition pcb_marker.h:137
std::vector< PCB_SHAPE > m_pathShapes
Definition pcb_marker.h:171
std::vector< PCB_SHAPE > GetErrorLegendShapes() const
const std::vector< PCB_SHAPE > & GetPath() const
Definition pcb_marker.h:163
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:58
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:149
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:83
static PCB_MARKER * FromLegacyString(const wxString &aData)
VECTOR2I GetCenter() const override
This defaults to the center of the bounding box if not overridden.
Definition pcb_marker.h:70
GAL_LAYER_ID GetColorLayer() const
VECTOR2I GetPosition() const override
Definition pcb_marker.h:67
bool Deserialize(const google::protobuf::Any &aContainer) override
Deserializes the given protobuf message into this object.
PCB_MARKER(std::shared_ptr< RC_ITEM > aItem, const VECTOR2I &aPos, int aLayer=F_Cu)
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:132
bool Matches(const EDA_SEARCH_DATA &aSearchData, void *aAuxData) const override
Compare the item against the search criteria in aSearchData.
Definition pcb_marker.h:113
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:156
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:174
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:75
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:91
void SetPosition(const VECTOR2I &aPos) override
Definition pcb_marker.h:68
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.
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
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:23
SEVERITY
@ PCB_MARKER_T
class PCB_MARKER, a marker used to show something
Definition typeinfo.h:91
VECTOR2< int32_t > VECTOR2I
Definition vector2d.h:683