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 <drc_item.h>
30 #include <gr_basic.h>
31 #include <eda_rect.h>
32 class SHAPE_LINE_CHAIN;
33 
34 /* Marker are mainly used to show a DRC or ERC error or warning
35  */
36 
37 
39 {
40 public:
41  enum TYPEMARKER { // Marker type: can be used to identify the purpose of the marker
46  };
47  enum MARKER_SEVERITY { // Severity of the marker: this is the level of error
52  };
53 
54  wxPoint m_Pos;
55 
56 protected:
65 
66  void init();
67 
68 public:
69 
70  MARKER_BASE( int aScalingFactor );
71 
82  MARKER_BASE( EDA_UNITS_T aUnits, int aErrorCode, const wxPoint& aMarkerPos,
83  EDA_ITEM* aItem, const wxPoint& aPos,
84  EDA_ITEM* bItem, const wxPoint& bPos, int aScalingFactor );
85 
96  MARKER_BASE( int aErrorCode, const wxPoint& aMarkerPos,
97  const wxString& aText, const wxPoint& aPos,
98  const wxString& bText, const wxPoint& bPos, int aScalingFactor );
99 
108  MARKER_BASE( int aErrorCode, const wxPoint& aMarkerPos,
109  const wxString& aText, const wxPoint& aPos, int aScalingFactor );
110 
117  MARKER_BASE( const MARKER_BASE& aMarker );
118 
119  ~MARKER_BASE();
120 
123  int MarkerScale() const { return m_ScalingFactor; }
124 
129  void ShapeToPolygon( SHAPE_LINE_CHAIN& aPolygon) const;
130 
133  const VECTOR2I* GetShapePolygon() const;
134 
137  const VECTOR2I& GetShapePolygonCorner( int aIdx ) const;
138 
141  int GetShapePolygonCornerCount() const;
142 
147  void PrintMarker( wxDC* aDC, const wxPoint& aOffset );
148 
153  const wxPoint& GetPos() const
154  {
155  return m_Pos;
156  }
157 
162  void SetColor( COLOR4D aColor )
163  {
164  m_Color = aColor;
165  }
166 
170  void SetErrorLevel( MARKER_SEVERITY aErrorLevel )
171  {
172  m_ErrorLevel = aErrorLevel;
173  }
174 
176  {
177  return m_ErrorLevel;
178  }
179 
182  void SetMarkerType( enum TYPEMARKER aMarkerType )
183  {
184  m_MarkerType = aMarkerType;
185  }
186 
188  {
189  return m_MarkerType;
190  }
191 
202  void SetData( EDA_UNITS_T aUnits, int aErrorCode, const wxPoint& aMarkerPos,
203  EDA_ITEM* aItem, const wxPoint& aPos,
204  EDA_ITEM* bItem = nullptr, const wxPoint& bPos = wxPoint() );
205 
216  void SetData( int aErrorCode, const wxPoint& aMarkerPos,
217  const wxString& aText, const wxPoint& aPos,
218  const wxString& bText = wxEmptyString, const wxPoint& bPos = wxPoint() );
219 
227  void SetAuxiliaryData( const wxString& aAuxiliaryText, const wxPoint& aAuxiliaryPos )
228  {
229  m_drc.SetAuxiliaryData( aAuxiliaryText, aAuxiliaryPos );
230  }
231 
233  {
235  }
236 
243  const DRC_ITEM& GetReporter() const
244  {
245  return m_drc;
246  }
247 
252  void DisplayMarkerInfo( EDA_DRAW_FRAME* aFrame );
253 
259  bool HitTestMarker( const wxPoint& aHitPosition, int aAccuracy ) const;
260 
269 };
270 
271 
272 #endif // MARKER_BASE_H
const wxPoint & GetPos() const
Function GetPos.
Definition: marker_base.h:153
MARKER_SEVERITY m_ErrorLevel
Specify the severity of the error.
Definition: marker_base.h:60
const DRC_ITEM & GetReporter() const
Function GetReporter returns the DRC_ITEM held within this MARKER so that its interface may be used.
Definition: marker_base.h:243
Class DRC_ITEM is a holder for a DRC (in Pcbnew) or ERC (in Eeschema) error item.
Definition: drc_item.h:48
int GetShapePolygonCornerCount() const
MARKER_SEVERITY GetErrorLevel() const
Definition: marker_base.h:175
void SetAuxiliaryData(const wxString &aAuxiliaryText, const wxPoint &aAuxiliaryPos)
Function SetAuxiliaryData initialize data for the second (auxiliary) item.
Definition: drc_item.h:154
void SetShowNoCoordinate()
Definition: marker_base.h:232
wxPoint m_Pos
position of the marker
Definition: marker_base.h:54
void SetData(EDA_UNITS_T 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.
const VECTOR2I * GetShapePolygon() const
The base class for create windows for drawing purpose.
MARKER_BASE(int aScalingFactor)
Definition: marker_base.cpp:99
TYPEMARKER m_MarkerType
The type of marker (useful to filter markers)
Definition: marker_base.h:59
EDA_RECT GetBoundingBoxMarker() const
Function GetBoundingBoxMarker returns the orthogonal, bounding box of this object for display purpose...
void DisplayMarkerInfo(EDA_DRAW_FRAME *aFrame)
Function DisplayMarkerInfo displays the full info of this marker, in a HTML window.
bool HitTestMarker(const wxPoint &aHitPosition, int aAccuracy) const
Tests if the given wxPoint is within the bounds of this object.
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...
COLOR4D m_Color
color
Definition: marker_base.h:61
int m_ScalingFactor
Scaling factor to convert corners coordinates to internat units coordinates.
Definition: marker_base.h:57
void SetMarkerType(enum TYPEMARKER aMarkerType)
accessors to set/get marker type (DRC, ERC, or other)
Definition: marker_base.h:182
EDA_RECT m_ShapeBoundingBox
Bounding box of the graphic symbol, relative to the position of the shape, in marker shape units.
Definition: marker_base.h:62
void SetShowNoCoordinate()
Definition: drc_item.h:169
int MarkerScale() const
The scaling factor to convert polygonal shape coordinates to internal units.
Definition: marker_base.h:123
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:187
Class SHAPE_LINE_CHAIN.
void SetErrorLevel(MARKER_SEVERITY aErrorLevel)
accessors to set/get error levels (warning, error, fatal error..)
Definition: marker_base.h:170
const VECTOR2I & GetShapePolygonCorner(int aIdx) const
Class EDA_RECT handles the component boundary box.
Definition: eda_rect.h:44
Class EDA_ITEM is a base class for most all the KiCad significant classes, used in schematics and boa...
Definition: base_struct.h:163
void SetColor(COLOR4D aColor)
Function SetColor Set the color of this marker.
Definition: marker_base.h:162
DRC_ITEM m_drc
Definition: marker_base.h:64
EDA_UNITS_T
Definition: common.h:154
void SetAuxiliaryData(const wxString &aAuxiliaryText, const wxPoint &aAuxiliaryPos)
Function SetAuxiliaryData initialize data for the second (auxiliary) item.
Definition: marker_base.h:227
Class COLOR4D is the color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:39