KiCad PCB EDA Suite
sch_marker.cpp
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 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com
5  * Copyright (C) 1992-2017 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 
30 #include <fctsys.h>
31 #include <class_drawpanel.h>
32 #include <trigo.h>
33 #include <msgpanel.h>
34 #include <bitmaps.h>
35 
36 #include <sch_marker.h>
37 #include <erc.h>
38 
39 
41 {
42 }
43 
44 
45 SCH_MARKER::SCH_MARKER( const wxPoint& pos, const wxString& text ) :
46  SCH_ITEM( NULL, SCH_MARKER_T ),
47  MARKER_BASE( 0, pos, text, pos )
48 {
49 }
50 
51 
53 {
54  return new SCH_MARKER( *this );
55 }
56 
57 
58 #if defined(DEBUG)
59 
60 void SCH_MARKER::Show( int nestLevel, std::ostream& os ) const
61 {
62  // for now, make it look like XML:
63  NestedSpace( nestLevel, os ) << '<' << GetClass().Lower().mb_str()
64  << GetPos() << "/>\n";
65 }
66 
67 #endif
68 
69 
70 void SCH_MARKER::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC,
71  const wxPoint& aOffset, GR_DRAWMODE aDrawMode, COLOR4D aColor )
72 {
74  COLOR4D tmp = color;
75 
77  {
80  }
81 
82  if( aColor == COLOR4D::UNSPECIFIED )
83  m_Color = color;
84  else
85  m_Color = aColor;
86 
87  DrawMarker( aPanel, aDC, aDrawMode, aOffset );
88  m_Color = tmp;
89 }
90 
91 
92 bool SCH_MARKER::Matches( wxFindReplaceData& aSearchData, void* aAuxData,
93  wxPoint * aFindLocation )
94 {
95  if( SCH_ITEM::Matches( m_drc.GetErrorText(), aSearchData ) ||
96  SCH_ITEM::Matches( m_drc.GetMainText(), aSearchData ) ||
97  SCH_ITEM::Matches( m_drc.GetAuxiliaryText(), aSearchData ) )
98  {
99  if( aFindLocation )
100  *aFindLocation = m_Pos;
101 
102  return true;
103  }
104 
105  return false;
106 }
107 
108 
110 {
111  return GetBoundingBoxMarker();
112 }
113 
114 
116 {
117  wxString msg;
118 
119  aList.push_back( MSG_PANEL_ITEM( _( "Electronics Rule Check Error" ),
120  GetReporter().GetErrorText(), DARKRED ) );
121 }
122 
123 
125 {
126  return erc_xpm;
127 }
128 
129 
130 void SCH_MARKER::Rotate( wxPoint aPosition )
131 {
132  RotatePoint( &m_Pos, aPosition, 900 );
133 }
134 
135 
136 void SCH_MARKER::MirrorX( int aXaxis_position )
137 {
138  m_Pos.y -= aXaxis_position;
139  m_Pos.y = -m_Pos.y;
140  m_Pos.y += aXaxis_position;
141 }
142 
143 
144 void SCH_MARKER::MirrorY( int aYaxis_position )
145 {
146  m_Pos.x -= aYaxis_position;
147  m_Pos.x = -m_Pos.x;
148  m_Pos.x += aYaxis_position;
149 }
150 
151 
152 bool SCH_MARKER::IsSelectStateChanged( const wxRect& aRect )
153 {
154  bool previousState = IsSelected();
155 
156  if( aRect.Contains( m_Pos ) )
157  SetFlags( SELECTED );
158  else
159  ClearFlags( SELECTED );
160 
161  return previousState != IsSelected();
162 }
163 
164 
165 bool SCH_MARKER::HitTest( const wxPoint& aPosition, int aAccuracy ) const
166 {
167  return HitTestMarker( aPosition );
168 }
void MirrorX(int aXaxis_position) override
Function MirrorX mirrors item relative to the X axis about aXaxis_position.
Definition: sch_marker.cpp:136
EDA_RECT const GetBoundingBox() const override
Function GetBoundingBox returns the orthogonal, bounding box of this object for display purposes...
Definition: sch_marker.cpp:109
bool HitTestMarker(const wxPoint &ref_pos) const
Function HitTestMarker tests if the given wxPoint is within the bounds of this object.
PNG memory record (file in memory).
Definition: bitmap_types.h:41
const wxPoint & GetPos() const
Function GetPos returns the position of this MARKER, const.
Definition: marker_base.h:116
void Draw(EDA_DRAW_PANEL *aPanel, wxDC *aDC, const wxPoint &aOffset, GR_DRAWMODE aDraw_mode, COLOR4D aColor=COLOR4D::UNSPECIFIED) override
Function Draw Draw a schematic item.
Definition: sch_marker.cpp:70
bool HitTest(const wxPoint &aPosition, int aAccuracy) const override
Function HitTest tests if aPosition is contained within or on the bounding box of an item...
Definition: sch_marker.cpp:165
wxString GetErrorText() const
Function GetErrorText returns the string form of a drc error code.
Definition: drc_item.cpp:38
EDA_RECT GetBoundingBoxMarker() const
Function GetBoundingBoxMarker returns the orthogonal, bounding box of this object for display purpose...
virtual bool Matches(wxFindReplaceData &aSearchData, void *aAuxData, wxPoint *aFindLocation)
Function Matches compares the item against the search criteria in aSearchData.
Definition: base_struct.h:429
int color
Definition: DXF_plotter.cpp:62
wxPoint m_Pos
position of the marker
Definition: marker_base.h:53
void GetMsgPanelInfo(std::vector< MSG_PANEL_ITEM > &aList) override
Function GetMsgPanelInfo populates aList of MSG_PANEL_ITEM objects with it&#39;s internal state for displ...
Definition: sch_marker.cpp:115
wxString GetMainText() const
acces to A and B texts
Definition: drc_item.h:137
bool IsSelected() const
Definition: base_struct.h:250
void RotatePoint(int *pX, int *pY, double angle)
Definition: trigo.cpp:317
COLOR4D GetLayerColor(SCH_LAYER_ID aLayer)
Definition: eeschema.cpp:167
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)...
Definition: colors.h:54
enum TYPEMARKER GetMarkerType() const
Definition: marker_base.h:150
void MirrorY(int aYaxis_position) override
Function MirrorY mirrors item relative to the Y axis about aYaxis_position.
Definition: sch_marker.cpp:144
BITMAP_DEF GetMenuImage() const override
Function GetMenuImage returns a pointer to an image to be used in menus.
Definition: sch_marker.cpp:124
#define SELECTED
Definition: base_struct.h:134
MARKER_SEVERITY GetErrorLevel() const
Definition: marker_base.h:138
void SetFlags(STATUS_FLAGS aMask)
Definition: base_struct.h:282
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:203
COLOR4D m_Color
color
Definition: marker_base.h:58
bool Matches(wxFindReplaceData &aSearchData, void *aAuxData, wxPoint *aFindLocation) override
Compare DRC marker main and auxiliary text against search string.
Definition: sch_marker.cpp:92
wxString GetAuxiliaryText() const
Definition: drc_item.h:138
void Rotate(wxPoint aPosition) override
Function Rotate rotates the item around aPosition 90 degrees in the clockwise direction.
Definition: sch_marker.cpp:130
EDA_ITEM * Clone() const override
Function Clone creates a duplicate of this item with linked list members set to NULL.
Definition: sch_marker.cpp:52
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:180
std::vector< MSG_PANEL_ITEM > MSG_PANEL_ITEMS
Definition: msgpanel.h:102
void ClearFlags(STATUS_FLAGS aMask=EDA_ITEM_ALL_FLAGS)
Definition: base_struct.h:283
wxString GetClass() const override
Function GetClass returns the class name.
Definition: sch_marker.h:50
bool IsSelectStateChanged(const wxRect &aRect) override
Function IsSelectStateChanged checks if the selection state of an item inside aRect has changed...
Definition: sch_marker.cpp:152
Class EDA_MSG_ITEM is used EDA_MSG_PANEL as the item type for displaying messages.
Definition: msgpanel.h:53
Message panel definition file.
Class SCH_ITEM is a base class for any item which can be embedded within the SCHEMATIC container clas...
DRC_ITEM m_drc
Definition: marker_base.h:64
Class COLOR4D is the color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:39