KiCad PCB EDA Suite
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) 1992-2014 KiCad Developers, see CHANGELOG.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 <rc_item.h>
30 #include <gr_basic.h>
31 #include <eda_rect.h>
32 
33 
34 class SHAPE_LINE_CHAIN;
35 
36 /*
37  * Marker are mainly used to show a DRC or ERC error or warning
38  */
39 
40 
42 {
43 public:
44  enum TYPEMARKER {
49  };
50 
52 
53 protected:
54  TYPEMARKER m_markerType; // The type of marker (useful to filter markers)
55  bool m_excluded; // User has excluded this specific error
57 
58  int m_scalingFactor; // Scaling factor to convert corners coordinates
59  // to internat units coordinates
60  EDA_RECT m_shapeBoundingBox; // Bounding box of the graphic symbol, relative
61  // to the position of the shape, in marker shape
62  // units
63 
64 public:
65 
66  MARKER_BASE( int aScalingFactor, RC_ITEM* aItem, TYPEMARKER aType = MARKER_UNSPEC );
67 
68  virtual ~MARKER_BASE();
69 
72  int MarkerScale() const { return m_scalingFactor; }
73 
78  void ShapeToPolygon( SHAPE_LINE_CHAIN& aPolygon) const;
79 
84  void PrintMarker( wxDC* aDC, const wxPoint& aOffset );
85 
90  const wxPoint& GetPos() const { return m_Pos; }
91 
92  virtual const KIID GetUUID() const = 0;
93 
97  void SetMarkerType( enum TYPEMARKER aMarkerType ) { m_markerType = aMarkerType; }
98  enum TYPEMARKER GetMarkerType() const { return m_markerType; }
99 
110  void SetData( EDA_UNITS aUnits, int aErrorCode, const wxPoint& aMarkerPos,
111  EDA_ITEM* aItem, const wxPoint& aPos,
112  EDA_ITEM* bItem = nullptr, const wxPoint& bPos = wxPoint() );
113 
124  void SetData( int aErrorCode, const wxPoint& aMarkerPos,
125  const wxString& aText, const wxPoint& aPos,
126  const wxString& bText = wxEmptyString, const wxPoint& bPos = wxPoint() );
127 
138  void SetData( EDA_UNITS aUnits, int aErrorCode, const wxPoint& aMarkerPos,
139  EDA_ITEM* aItem,
140  EDA_ITEM* bItem = nullptr );
141 
152  void SetData( int aErrorCode, const wxPoint& aMarkerPos,
153  const wxString& aText,
154  const wxString& bText = wxEmptyString );
155 
156  void SetData( int aErrorCode, const wxPoint& aMarkerPos,
157  const wxString& aText, const KIID& aID,
158  const wxString& bText = wxEmptyString, const KIID& bID = niluuid );
159 
167  void SetAuxiliaryData( const wxString& aAuxiliaryText, const wxPoint& aAuxiliaryPos )
168  {
169  m_rcItem->SetAuxiliaryData( aAuxiliaryText, aAuxiliaryPos );
170  }
171 
172  bool IsExcluded() const { return m_excluded; }
173  void SetExcluded( bool aExcluded ) { m_excluded = aExcluded; }
174 
181  RC_ITEM* GetRCItem() { return m_rcItem; }
182  const RC_ITEM* GetRCItem() const { return m_rcItem; }
183 
189  bool HitTestMarker( const wxPoint& aHitPosition, int aAccuracy ) const;
190 
199 
200 protected:
201  virtual KIGFX::COLOR4D getColor() const = 0;
202 };
203 
204 
205 #endif // MARKER_BASE_H
EDA_UNITS
Definition: common.h:184
const wxPoint & GetPos() const
Function GetPos.
Definition: marker_base.h:90
MARKER_BASE(int aScalingFactor, RC_ITEM *aItem, TYPEMARKER aType=MARKER_UNSPEC)
Definition: marker_base.cpp:62
RC_ITEM * GetRCItem()
Function GetReporter returns the DRC_ITEM held within this MARKER so that its interface may be used.
Definition: marker_base.h:181
bool m_excluded
Definition: marker_base.h:55
virtual ~MARKER_BASE()
Definition: marker_base.cpp:86
RC_ITEM is a holder for a DRC (in Pcbnew) or ERC (in Eeschema) error item.
Definition: rc_item.h:82
wxPoint m_Pos
position of the marker
Definition: marker_base.h:51
TYPEMARKER m_markerType
Definition: marker_base.h:54
virtual KIGFX::COLOR4D getColor() const =0
EDA_RECT GetBoundingBoxMarker() const
Function GetBoundingBoxMarker returns the orthogonal, bounding box of this object for display purpose...
RC_ITEM * m_rcItem
Definition: marker_base.h:56
Definition: common.h:65
bool HitTestMarker(const wxPoint &aHitPosition, int aAccuracy) const
Tests if the given wxPoint is within the bounds of this object.
void SetExcluded(bool aExcluded)
Definition: marker_base.h:173
EDA_RECT m_shapeBoundingBox
Definition: marker_base.h:60
KIID niluuid(0)
void ShapeToPolygon(SHAPE_LINE_CHAIN &aPolygon) const
Returns the shape polygon in internal units in a SHAPE_LINE_CHAIN the coordinates are relatives to th...
bool IsExcluded() const
Definition: marker_base.h:172
void SetMarkerType(enum TYPEMARKER aMarkerType)
accessors to set/get marker type (DRC, ERC, or other)
Definition: marker_base.h:97
int m_scalingFactor
Definition: marker_base.h:58
int MarkerScale() const
The scaling factor to convert polygonal shape coordinates to internal units.
Definition: marker_base.h:72
void PrintMarker(wxDC *aDC, const wxPoint &aOffset)
Function PrintMarker Prints the shape is the polygon defined in m_Corners (array of wxPoints).
enum TYPEMARKER GetMarkerType() const
Definition: marker_base.h:98
SHAPE_LINE_CHAIN.
EDA_RECT handles the component boundary box.
Definition: eda_rect.h:44
EDA_ITEM is a base class for most all the KiCad significant classes, used in schematics and boards.
Definition: base_struct.h:166
const RC_ITEM * GetRCItem() const
Definition: marker_base.h:182
void SetData(EDA_UNITS aUnits, int aErrorCode, const wxPoint &aMarkerPos, EDA_ITEM *aItem, const wxPoint &aPos, EDA_ITEM *bItem=nullptr, const wxPoint &bPos=wxPoint())
Function SetData fills in all the reportable data associated with a MARKER.
Definition: marker_base.cpp:91
virtual const KIID GetUUID() const =0
void SetAuxiliaryData(const wxString &aAuxiliaryText, const wxPoint &aAuxiliaryPos)
Function SetAuxiliaryData initialize data for the second (auxiliary) item.
Definition: marker_base.h:167
void SetAuxiliaryData(const wxString &aAuxiliaryText, const wxPoint &aAuxiliaryPos)
Function SetAuxiliaryData initialize data for the second (auxiliary) item.
Definition: rc_item.h:247
COLOR4D is the color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:40