KiCad PCB EDA Suite
Loading...
Searching...
No Matches
marker_base.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-2014 Jean-Pierre Charras, jp.charras at wanadoo.fr
5 * Copyright (C) 2009-2020 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
26#ifndef MARKER_BASE_H
27#define MARKER_BASE_H
28
29#include <memory>
30
31#include <rc_item.h>
32#include <gr_basic.h>
33
34
36
37namespace KIGFX
38{
39 class RENDER_SETTINGS;
40}
41
43
44
45/*
46 * Marker are mainly used to show a DRC or ERC error or warning
47 */
49{
50public:
52 {
60 };
61
62 MARKER_BASE( int aScalingFactor, std::shared_ptr<RC_ITEM> aItem,
63 MARKER_T aType = MARKER_UNSPEC );
64 virtual ~MARKER_BASE();
65
69 int MarkerScale() const { return m_scalingFactor; }
70 void SetMarkerScale( int aScale ) { m_scalingFactor = aScale; }
71
78 void ShapeToPolygon( SHAPE_LINE_CHAIN& aPolygon, int aScale = -1 ) const;
79
83 void PrintMarker( const RENDER_SETTINGS* aSettings, const VECTOR2I& aOffset );
84
88 const VECTOR2I& GetPos() const { return m_Pos; }
89
90 virtual const KIID GetUUID() const = 0;
91
95 void SetMarkerType( enum MARKER_T aMarkerType ) { m_markerType = aMarkerType; }
96 enum MARKER_T GetMarkerType() const { return m_markerType; }
97
98 bool IsExcluded() const { return m_excluded; }
99 void SetExcluded( bool aExcluded, const wxString& aComment = wxEmptyString )
100 {
101 m_excluded = aExcluded;
102 m_comment = aComment;
103 }
104
105 wxString GetComment() const { return m_comment; }
106
107 virtual SEVERITY GetSeverity() const { return RPT_SEVERITY_UNDEFINED; }
108
112 std::shared_ptr<RC_ITEM> GetRCItem() const { return m_rcItem; }
113
120 bool HitTestMarker( const VECTOR2I& aHitPosition, int aAccuracy ) const;
121
125 bool HitTestMarker( const BOX2I& aRect, bool aContained, int aAccuracy = 0 ) const;
126
135
136protected:
137 virtual KIGFX::COLOR4D getColor() const = 0;
138
139public:
141
142protected:
143 MARKER_T m_markerType; // The type of marker (useful to filter markers)
144 bool m_excluded; // User has excluded this specific error
145 wxString m_comment; // User-supplied comment (generally for exclusions)
146 std::shared_ptr<RC_ITEM> m_rcItem;
147
148 int m_scalingFactor; // Scaling factor to convert corners coordinates
149 // to internal units coordinates
150 BOX2I m_shapeBoundingBox; // Bounding box of the graphic symbol, relative
151 // to the position of the shape, in marker shape
152 // units
153};
154
155
156#endif // MARKER_BASE_H
A color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:104
Container for all the knowledge about how graphical objects are drawn on any output surface/device.
Definition: kiid.h:49
void PrintMarker(const RENDER_SETTINGS *aSettings, const VECTOR2I &aOffset)
Print the shape is the polygon defined in m_Corners (array of VECTOR2Is).
virtual SEVERITY GetSeverity() const
Definition: marker_base.h:107
bool IsExcluded() const
Definition: marker_base.h:98
bool HitTestMarker(const VECTOR2I &aHitPosition, int aAccuracy) const
Test if the given VECTOR2I is within the bounds of this object.
Definition: marker_base.cpp:90
virtual KIGFX::COLOR4D getColor() const =0
std::shared_ptr< RC_ITEM > GetRCItem() const
Definition: marker_base.h:112
int m_scalingFactor
Definition: marker_base.h:148
wxString m_comment
Definition: marker_base.h:145
int MarkerScale() const
The scaling factor to convert polygonal shape coordinates to internal units.
Definition: marker_base.h:69
const VECTOR2I & GetPos() const
Definition: marker_base.h:88
VECTOR2I m_Pos
position of the marker
Definition: marker_base.h:140
@ MARKER_DRAWING_SHEET
Definition: marker_base.h:56
void SetExcluded(bool aExcluded, const wxString &aComment=wxEmptyString)
Definition: marker_base.h:99
virtual const KIID GetUUID() const =0
virtual ~MARKER_BASE()
Definition: marker_base.cpp:85
void SetMarkerScale(int aScale)
Definition: marker_base.h:70
void SetMarkerType(enum MARKER_T aMarkerType)
Accessors to set/get marker type (DRC, ERC, or other)
Definition: marker_base.h:95
MARKER_T m_markerType
Definition: marker_base.h:143
bool m_excluded
Definition: marker_base.h:144
std::shared_ptr< RC_ITEM > m_rcItem
Definition: marker_base.h:146
enum MARKER_T GetMarkerType() const
Definition: marker_base.h:96
BOX2I m_shapeBoundingBox
Definition: marker_base.h:150
void ShapeToPolygon(SHAPE_LINE_CHAIN &aPolygon, int aScale=-1) const
Return the shape polygon in internal units in a SHAPE_LINE_CHAIN the coordinates are relatives to the...
wxString GetComment() const
Definition: marker_base.h:105
BOX2I GetBoundingBoxMarker() const
Return the orthogonal, bounding box of this object for display purposes.
Represent a polyline containing arcs as well as line segments: A chain of connected line and/or arc s...
The Cairo implementation of the graphics abstraction layer.
Definition: color4d.cpp:247
SEVERITY
@ RPT_SEVERITY_UNDEFINED