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
33class PCB_MARKER : public BOARD_ITEM, public MARKER_BASE
34{
35public:
36 PCB_MARKER( std::shared_ptr<RC_ITEM> aItem, const VECTOR2I& aPos, int aLayer = F_Cu );
37
39
40 static inline bool ClassOf( const EDA_ITEM* aItem )
41 {
42 return aItem && PCB_MARKER_T == aItem->Type();
43 }
44
45 const KIID GetUUID() const override { return m_Uuid; }
46
47 wxString SerializeToString() const;
48
49 static PCB_MARKER* DeserializeFromString( const wxString& data );
50
51 void Move( const VECTOR2I& aMoveVector ) override
52 {
53 m_Pos += aMoveVector;
54 }
55
56 void Rotate( const VECTOR2I& aRotCentre, const EDA_ANGLE& aAngle ) override;
57
58 void Flip( const VECTOR2I& aCentre, FLIP_DIRECTION aFlipDirection ) override;
59
60 VECTOR2I GetPosition() const override { return m_Pos; }
61 void SetPosition( const VECTOR2I& aPos ) override { m_Pos = aPos; }
62
63 VECTOR2I GetCenter() const override
64 {
65 return GetPosition();
66 }
67
68 bool HitTest( const VECTOR2I& aPosition, int aAccuracy = 0 ) const override
69 {
71 return false;
72 else
73 return HitTestMarker( aPosition, aAccuracy );
74 }
75
76 bool HitTest( const BOX2I& aRect, bool aContained, int aAccuracy = 0 ) const override
77 {
79 return false;
80
81 return HitTestMarker( aRect, aContained, aAccuracy );
82 }
83
84 bool HitTest( const SHAPE_LINE_CHAIN& aPoly, bool aContained ) const override
85 {
87 return false;
88
89 return HitTestMarker( aPoly, aContained );
90 }
91
92 EDA_ITEM* Clone() const override
93 {
94 return new PCB_MARKER( *this );
95 }
96
98
99 std::shared_ptr<SHAPE> GetEffectiveShape( PCB_LAYER_ID aLayer,
100 FLASHING aFlash = FLASHING::DEFAULT ) const override;
101
102 void TransformShapeToPolygon( SHAPE_POLY_SET& aBuffer, PCB_LAYER_ID aLayer, int aClearance,
103 int aError, ERROR_LOC aErrorLoc, bool ignoreLineWidth ) const override;
104
105
106 void GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITEM>& aList ) override;
107
108 bool Matches( const EDA_SEARCH_DATA& aSearchData, void* aAuxData ) const override
109 {
110 return BOARD_ITEM::Matches( m_rcItem->GetErrorMessage( true ), aSearchData );
111 }
112
113 wxString GetItemDescription( UNITS_PROVIDER* aUnitsProvider, bool aFull ) const override;
114
115 BITMAPS GetMenuImage() const override;
116
117 void SetZoom( double aZoomFactor ) const;
118
119 const BOX2I ViewBBox() const override;
120
121 const BOX2I GetBoundingBox() const override;
122
123 std::vector<int> ViewGetLayers() const override;
124
125 SEVERITY GetSeverity() const override;
126
127 double Similarity( const BOARD_ITEM& aBoardItem ) const override
128 {
129 return 0.0;
130 }
131
132 bool operator==( const BOARD_ITEM& aBoardItem ) const override
133 {
134 return false;
135 }
136
137#if defined(DEBUG)
138 void Show( int nestLevel, std::ostream& os ) const override { ShowDummy( os ); }
139#endif
140
144 virtual wxString GetClass() const override
145 {
146 return wxT( "PCB_MARKER" );
147 }
148
149 std::vector<PCB_SHAPE> GetShapes() const;
150
151 void SetPath( const std::vector<PCB_SHAPE>& aShapes, const VECTOR2I& aStart, const VECTOR2I& aEnd )
152 {
153 m_pathShapes = aShapes;
154 m_pathStart = aStart;
155 m_pathEnd = aEnd;
156 }
157
158 const std::vector<PCB_SHAPE>& GetPath() const { return m_pathShapes; }
159
160protected:
161 void swapData( BOARD_ITEM* aImage ) override;
162
163 KIGFX::COLOR4D getColor() const override;
164
165protected:
166 std::vector<PCB_SHAPE> m_pathShapes; // Shown on LAYER_DRC_SHAPES
170};
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:918
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
Definition board_item.h:81
BOARD_ITEM(BOARD_ITEM *aParent, KICAD_T idtype, PCB_LAYER_ID aLayer=F_Cu)
Definition board_item.h:83
The base class for create windows for drawing purpose.
const KIID m_Uuid
Definition eda_item.h:531
KICAD_T Type() const
Returns the type of object.
Definition eda_item.h:108
virtual bool Matches(const EDA_SEARCH_DATA &aSearchData, void *aAuxData) const
Compare the item against the search criteria in aSearchData.
Definition eda_item.h:416
EDA_ITEM(EDA_ITEM *parent, KICAD_T idType, bool isSCH_ITEM=false, bool isBOARD_ITEM=false)
Definition eda_item.cpp:37
A color representation with 4 components: red, green, blue, alpha.
Definition color4d.h:101
Definition kiid.h:44
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:45
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:168
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:167
std::vector< PCB_SHAPE > GetShapes() const
bool operator==(const BOARD_ITEM &aBoardItem) const override
Definition pcb_marker.h:132
std::vector< PCB_SHAPE > m_pathShapes
Definition pcb_marker.h:166
std::shared_ptr< SHAPE > GetEffectiveShape(PCB_LAYER_ID aLayer, FLASHING aFlash=FLASHING::DEFAULT) const override
Some pad shapes can be complex (rounded/chamfered rectangle), even without considering custom shapes.
const std::vector< PCB_SHAPE > & GetPath() const
Definition pcb_marker.h:158
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:51
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:144
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
static PCB_MARKER * DeserializeFromString(const wxString &data)
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:76
VECTOR2I GetCenter() const override
This defaults to the center of the bounding box if not overridden.
Definition pcb_marker.h:63
wxString SerializeToString() const
GAL_LAYER_ID GetColorLayer() const
VECTOR2I GetPosition() const override
Definition pcb_marker.h:60
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:40
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:127
bool Matches(const EDA_SEARCH_DATA &aSearchData, void *aAuxData) const override
Compare the item against the search criteria in aSearchData.
Definition pcb_marker.h:108
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:151
EDA_ITEM * Clone() const override
Create a duplicate of this item with linked list members set to NULL.
Definition pcb_marker.h:92
int m_pathLength
Definition pcb_marker.h:169
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:68
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:84
void SetPosition(const VECTOR2I &aPos) override
Definition pcb_marker.h:61
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.
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
@ 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:92
VECTOR2< int32_t > VECTOR2I
Definition vector2d.h:683