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 <memory>
30 
31 #include <rc_item.h>
32 #include <gr_basic.h>
33 #include <eda_rect.h>
34 
35 
36 class SHAPE_LINE_CHAIN;
37 
38 namespace KIGFX
39 {
40  class RENDER_SETTINGS;
41 }
42 
44 
45 
46 /*
47  * Marker are mainly used to show a DRC or ERC error or warning
48  */
49 
50 
52 {
53 public:
54  enum TYPEMARKER {
59  };
60 
62 
63 protected:
64  TYPEMARKER m_markerType; // The type of marker (useful to filter markers)
65  bool m_excluded; // User has excluded this specific error
66  std::shared_ptr<RC_ITEM> m_rcItem;
67 
68  int m_scalingFactor; // Scaling factor to convert corners coordinates
69  // to internat units coordinates
70  EDA_RECT m_shapeBoundingBox; // Bounding box of the graphic symbol, relative
71  // to the position of the shape, in marker shape
72  // units
73 
74 public:
75 
76  MARKER_BASE( int aScalingFactor, std::shared_ptr<RC_ITEM> aItem, TYPEMARKER aType = MARKER_UNSPEC );
77  virtual ~MARKER_BASE();
78 
81  int MarkerScale() const { return m_scalingFactor; }
82 
87  void ShapeToPolygon( SHAPE_LINE_CHAIN& aPolygon) const;
88 
93  void PrintMarker( RENDER_SETTINGS* aSettings, const wxPoint& aOffset );
94 
99  const wxPoint& GetPos() const { return m_Pos; }
100 
101  virtual const KIID GetUUID() const = 0;
102 
106  void SetMarkerType( enum TYPEMARKER aMarkerType ) { m_markerType = aMarkerType; }
107  enum TYPEMARKER GetMarkerType() const { return m_markerType; }
108 
109  bool IsExcluded() const { return m_excluded; }
110  void SetExcluded( bool aExcluded ) { m_excluded = aExcluded; }
111 
119  // fixme: use shared_ptr
120  std::shared_ptr<RC_ITEM> GetRCItem() const { return m_rcItem; }
121 
127  bool HitTestMarker( const wxPoint& aHitPosition, int aAccuracy ) const;
128 
137 
138 protected:
139  virtual KIGFX::COLOR4D getColor() const = 0;
140 };
141 
142 
143 #endif // MARKER_BASE_H
const wxPoint & GetPos() const
Function GetPos.
Definition: marker_base.h:99
Class CAIRO_GAL is the cairo implementation of the graphics abstraction layer.
Definition: color4d.cpp:175
bool m_excluded
Definition: marker_base.h:65
RENDER_SETTINGS Contains all the knowledge about how graphical objects are drawn on any output surfac...
virtual ~MARKER_BASE()
Definition: marker_base.cpp:86
wxPoint m_Pos
position of the marker
Definition: marker_base.h:61
TYPEMARKER m_markerType
Definition: marker_base.h:64
virtual KIGFX::COLOR4D getColor() const =0
EDA_RECT GetBoundingBoxMarker() const
Function GetBoundingBoxMarker returns the orthogonal, bounding box of this object for display purpose...
Definition: common.h:68
bool HitTestMarker(const wxPoint &aHitPosition, int aAccuracy) const
Tests if the given wxPoint is within the bounds of this object.
Definition: marker_base.cpp:91
void SetExcluded(bool aExcluded)
Definition: marker_base.h:110
std::shared_ptr< RC_ITEM > m_rcItem
Definition: marker_base.h:66
EDA_RECT m_shapeBoundingBox
Definition: marker_base.h:70
void PrintMarker(RENDER_SETTINGS *aSettings, const wxPoint &aOffset)
Function PrintMarker Prints the shape is the polygon defined in m_Corners (array of wxPoints).
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:109
void SetMarkerType(enum TYPEMARKER aMarkerType)
accessors to set/get marker type (DRC, ERC, or other)
Definition: marker_base.h:106
int m_scalingFactor
Definition: marker_base.h:68
int MarkerScale() const
The scaling factor to convert polygonal shape coordinates to internal units.
Definition: marker_base.h:81
MARKER_BASE(int aScalingFactor, std::shared_ptr< RC_ITEM > aItem, TYPEMARKER aType=MARKER_UNSPEC)
Definition: marker_base.cpp:62
enum TYPEMARKER GetMarkerType() const
Definition: marker_base.h:107
SHAPE_LINE_CHAIN.
EDA_RECT handles the component boundary box.
Definition: eda_rect.h:44
virtual const KIID GetUUID() const =0
std::shared_ptr< RC_ITEM > GetRCItem() const
Function GetReporter returns the DRC_ITEM held within this MARKER so that its interface may be used.
Definition: marker_base.h:120
COLOR4D is the color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:99