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 DrawMarker( EDA_DRAW_PANEL* aPanel, wxDC* aDC, GR_DRAWMODE aDrawMode,
148  const wxPoint& aOffset );
149 
154  const wxPoint& GetPos() const
155  {
156  return m_Pos;
157  }
158 
163  void SetColor( COLOR4D aColor )
164  {
165  m_Color = aColor;
166  }
167 
171  void SetErrorLevel( MARKER_SEVERITY aErrorLevel )
172  {
173  m_ErrorLevel = aErrorLevel;
174  }
175 
177  {
178  return m_ErrorLevel;
179  }
180 
183  void SetMarkerType( enum TYPEMARKER aMarkerType )
184  {
185  m_MarkerType = aMarkerType;
186  }
187 
189  {
190  return m_MarkerType;
191  }
192 
203  void SetData( EDA_UNITS_T aUnits, int aErrorCode, const wxPoint& aMarkerPos,
204  EDA_ITEM* aItem, const wxPoint& aPos,
205  EDA_ITEM* bItem = nullptr, const wxPoint& bPos = wxPoint() );
206 
217  void SetData( int aErrorCode, const wxPoint& aMarkerPos,
218  const wxString& aText, const wxPoint& aPos,
219  const wxString& bText = wxEmptyString, const wxPoint& bPos = wxPoint() );
220 
228  void SetAuxiliaryData( const wxString& aAuxiliaryText, const wxPoint& aAuxiliaryPos )
229  {
230  m_drc.SetAuxiliaryData( aAuxiliaryText, aAuxiliaryPos );
231  }
232 
234  {
235  m_drc.SetShowNoCoordinate();
236  }
237 
244  const DRC_ITEM& GetReporter() const
245  {
246  return m_drc;
247  }
248 
253  void DisplayMarkerInfo( EDA_DRAW_FRAME* aFrame );
254 
260  bool HitTestMarker( const wxPoint& aHitPosition ) const;
261 
270 };
271 
272 
273 #endif // MARKER_BASE_H
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...
MARKER_SEVERITY m_ErrorLevel
Specify the severity of the error.
Definition: marker_base.h:60
Class DRC_ITEM is a holder for a DRC (in Pcbnew) or ERC (in Eeschema) error item. ...
Definition: drc_item.h:48
const wxPoint & GetPos() const
Function GetPos.
Definition: marker_base.h:154
EDA_RECT GetBoundingBoxMarker() const
Function GetBoundingBoxMarker returns the orthogonal, bounding box of this object for display purpose...
void SetAuxiliaryData(const wxString &aAuxiliaryText, const wxPoint &aAuxiliaryPos)
Function SetAuxiliaryData initialize data for the second (auxiliary) item.
Definition: drc_item.h:142
void SetShowNoCoordinate()
Definition: marker_base.h:233
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.
int GetShapePolygonCornerCount() const
The base class for create windows for drawing purpose.
Definition: draw_frame.h:78
int MarkerScale() const
The scaling factor to convert polygonal shape coordinates to internal units.
Definition: marker_base.h:123
void DrawMarker(EDA_DRAW_PANEL *aPanel, wxDC *aDC, GR_DRAWMODE aDrawMode, const wxPoint &aOffset)
Function DrawMarker draws the shape is the polygon defined in m_Corners (array of wxPoints)...
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
bool HitTestMarker(const wxPoint &aHitPosition) const
Tests if the given wxPoint is within the bounds of this object.
enum TYPEMARKER GetMarkerType() const
Definition: marker_base.h:188
void DisplayMarkerInfo(EDA_DRAW_FRAME *aFrame)
Function DisplayMarkerInfo displays the full info of this marker, in a HTML window.
MARKER_SEVERITY GetErrorLevel() const
Definition: marker_base.h:176
GR_DRAWMODE
Drawmode. Compositing mode plus a flag or two.
Definition: gr_basic.h:37
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:244
COLOR4D m_Color
color
Definition: marker_base.h:61
const VECTOR2I & GetShapePolygonCorner(int aIdx) const
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:183
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:157
Class SHAPE_LINE_CHAIN.
void SetErrorLevel(MARKER_SEVERITY aErrorLevel)
accessors to set/get error levels (warning, error, fatal error..)
Definition: marker_base.h:171
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:154
void SetColor(COLOR4D aColor)
Function SetColor Set the color of this marker.
Definition: marker_base.h:163
const VECTOR2I * GetShapePolygon() const
DRC_ITEM m_drc
Definition: marker_base.h:64
EDA_UNITS_T
Definition: common.h:160
void SetAuxiliaryData(const wxString &aAuxiliaryText, const wxPoint &aAuxiliaryPos)
Function SetAuxiliaryData initialize data for the second (auxiliary) item.
Definition: marker_base.h:228
Class COLOR4D is the color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:39