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, you may find one here:
19 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
20 * or you may search the http://www.gnu.org 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 */
24
25#pragma once
26
27
28#include <board_item.h>
29#include <pcb_shape.h>
30#include <rc_item.h>
31#include <marker_base.h>
32
33class DRC_ITEM;
34class MSG_PANEL_ITEM;
35
36
37class PCB_MARKER : public BOARD_ITEM, public MARKER_BASE
38{
39public:
40 PCB_MARKER( std::shared_ptr<RC_ITEM> aItem, const VECTOR2I& aPos, int aLayer = F_Cu );
41
43
44 static inline bool ClassOf( const EDA_ITEM* aItem )
45 {
46 return aItem && PCB_MARKER_T == aItem->Type();
47 }
48
49 const KIID GetUUID() const override { return m_Uuid; }
50
51 wxString SerializeToString() const;
52
53 static PCB_MARKER* DeserializeFromString( const wxString& data );
54
55 void Move( const VECTOR2I& aMoveVector ) override
56 {
57 m_Pos += aMoveVector;
58 }
59
60 void Rotate( const VECTOR2I& aRotCentre, const EDA_ANGLE& aAngle ) override;
61
62 void Flip( const VECTOR2I& aCentre, FLIP_DIRECTION aFlipDirection ) override;
63
64 VECTOR2I GetPosition() const override { return m_Pos; }
65 void SetPosition( const VECTOR2I& aPos ) override { m_Pos = aPos; }
66
67 VECTOR2I GetCenter() const override
68 {
69 return GetPosition();
70 }
71
72 bool HitTest( const VECTOR2I& aPosition, int aAccuracy = 0 ) const override
73 {
75 return false;
76 else
77 return HitTestMarker( aPosition, aAccuracy );
78 }
79
80 bool HitTest( const BOX2I& aRect, bool aContained, int aAccuracy = 0 ) const override
81 {
83 return false;
84
85 return HitTestMarker( aRect, aContained, aAccuracy );
86 }
87
88 bool HitTest( const SHAPE_LINE_CHAIN& aPoly, bool aContained ) const override
89 {
91 return false;
92
93 return HitTestMarker( aPoly, aContained );
94 }
95
96 EDA_ITEM* Clone() const override
97 {
98 return new PCB_MARKER( *this );
99 }
100
102
103 std::shared_ptr<SHAPE> GetEffectiveShape( PCB_LAYER_ID aLayer,
104 FLASHING aFlash = FLASHING::DEFAULT ) const override;
105
106 void TransformShapeToPolygon( SHAPE_POLY_SET& aBuffer, PCB_LAYER_ID aLayer, int aClearance,
107 int aError, ERROR_LOC aErrorLoc, bool ignoreLineWidth ) const override;
108
109
110 void GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITEM>& aList ) override;
111
112 bool Matches( const EDA_SEARCH_DATA& aSearchData, void* aAuxData ) const override
113 {
114 return BOARD_ITEM::Matches( m_rcItem->GetErrorMessage(), aSearchData );
115 }
116
117 wxString GetItemDescription( UNITS_PROVIDER* aUnitsProvider, bool aFull ) const override;
118
119 BITMAPS GetMenuImage() const override;
120
121 void SetZoom( double aZoomFactor ) const;
122
123 const BOX2I ViewBBox() const override;
124
125 const BOX2I GetBoundingBox() const override;
126
127 std::vector<int> ViewGetLayers() const override;
128
129 SEVERITY GetSeverity() const override;
130
131 double Similarity( const BOARD_ITEM& aBoardItem ) const override
132 {
133 return 0.0;
134 }
135
136 bool operator==( const BOARD_ITEM& aBoardItem ) const override
137 {
138 return false;
139 }
140
141#if defined(DEBUG)
142 void Show( int nestLevel, std::ostream& os ) const override { ShowDummy( os ); }
143#endif
144
148 virtual wxString GetClass() const override
149 {
150 return wxT( "PCB_MARKER" );
151 }
152
153 std::vector<PCB_SHAPE> GetShapes() const { return m_shapes; };
154 void SetShapes( const std::vector<PCB_SHAPE>& aShapes ) { m_shapes = aShapes; };
155
156protected:
157 KIGFX::COLOR4D getColor() const override;
158
159protected:
160 std::vector<PCB_SHAPE> m_shapes; // Shown on LAYER_DRC_SHAPES
161};
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:922
BOARD_ITEM(BOARD_ITEM *aParent, KICAD_T idtype, PCB_LAYER_ID aLayer=F_Cu)
Definition board_item.h:81
The base class for create windows for drawing purpose.
const KIID m_Uuid
Definition eda_item.h:516
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:401
EDA_ITEM(EDA_ITEM *parent, KICAD_T idType, bool isSCH_ITEM=false, bool isBOARD_ITEM=false)
Definition eda_item.cpp:39
A color representation with 4 components: red, green, blue, alpha.
Definition color4d.h:104
Definition kiid.h:49
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:91
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:54
const KIID GetUUID() const override
Definition pcb_marker.h:49
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.
std::vector< PCB_SHAPE > m_shapes
Definition pcb_marker.h:160
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.
std::vector< PCB_SHAPE > GetShapes() const
Definition pcb_marker.h:153
bool operator==(const BOARD_ITEM &aBoardItem) const override
Definition pcb_marker.h:136
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.
void SetShapes(const std::vector< PCB_SHAPE > &aShapes)
Definition pcb_marker.h:154
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:55
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:148
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:80
VECTOR2I GetCenter() const override
This defaults to the center of the bounding box if not overridden.
Definition pcb_marker.h:67
wxString SerializeToString() const
GAL_LAYER_ID GetColorLayer() const
VECTOR2I GetPosition() const override
Definition pcb_marker.h:64
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:44
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:131
bool Matches(const EDA_SEARCH_DATA &aSearchData, void *aAuxData) const override
Compare the item against the search criteria in aSearchData.
Definition pcb_marker.h:112
wxString GetItemDescription(UNITS_PROVIDER *aUnitsProvider, bool aFull) const override
Return a user-visible description string of this item.
EDA_ITEM * Clone() const override
Create a duplicate of this item with linked list members set to NULL.
Definition pcb_marker.h:96
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:72
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:88
void SetPosition(const VECTOR2I &aPos) override
Definition pcb_marker.h:65
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:184
@ DEFAULT
Flashing follows connectivity.
Definition layer_ids.h:185
GAL_LAYER_ID
GAL layers are "virtual" layers, i.e.
Definition layer_ids.h:228
PCB_LAYER_ID
A quick note on layer IDs:
Definition layer_ids.h:60
@ F_Cu
Definition layer_ids.h:64
FLIP_DIRECTION
Definition mirror.h:27
SEVERITY
@ PCB_MARKER_T
class PCB_MARKER, a marker used to show something
Definition typeinfo.h:99
VECTOR2< int32_t > VECTOR2I
Definition vector2d.h:695