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-2011 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 <wxstruct.h>
32 #include <class_drawpanel.h>
33 #include <trigo.h>
34 #include <msgpanel.h>
35 #include <bitmaps.h>
36 
37 #include <general.h>
38 #include <sch_marker.h>
39 #include <erc.h>
40 
41 
42 /********************/
43 /* class SCH_MARKER */
44 /********************/
45 
47 {
48 }
49 
50 
51 SCH_MARKER::SCH_MARKER( const wxPoint& pos, const wxString& text ) :
52  SCH_ITEM( NULL, SCH_MARKER_T ),
53  MARKER_BASE( 0, pos, text, pos )
54 {
55 }
56 
57 
59 {
60  return new SCH_MARKER( *this );
61 }
62 
63 
64 #if defined(DEBUG)
65 
66 void SCH_MARKER::Show( int nestLevel, std::ostream& os ) const
67 {
68  // for now, make it look like XML:
69  NestedSpace( nestLevel, os ) << '<' << GetClass().Lower().mb_str()
70  << GetPos() << "/>\n";
71 }
72 
73 #endif
74 
81 bool SCH_MARKER::Save( FILE* aFile ) const
82 {
83  return true;
84 }
85 
86 
87 void SCH_MARKER::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC,
88  const wxPoint& aOffset, GR_DRAWMODE aDrawMode, COLOR4D aColor )
89 {
91  COLOR4D tmp = color;
92 
94  {
97  }
98 
99  if( aColor == COLOR4D::UNSPECIFIED )
100  m_Color = color;
101  else
102  m_Color = aColor;
103 
104  DrawMarker( aPanel, aDC, aDrawMode, aOffset );
105  m_Color = tmp;
106 }
107 
108 
109 bool SCH_MARKER::Matches( wxFindReplaceData& aSearchData, void* aAuxData,
110  wxPoint * aFindLocation )
111 {
112  if( SCH_ITEM::Matches( m_drc.GetErrorText(), aSearchData ) ||
113  SCH_ITEM::Matches( m_drc.GetMainText(), aSearchData ) ||
114  SCH_ITEM::Matches( m_drc.GetAuxiliaryText(), aSearchData ) )
115  {
116  if( aFindLocation )
117  *aFindLocation = m_Pos;
118 
119  return true;
120  }
121 
122  return false;
123 }
124 
125 
134 {
135  return GetBoundingBoxMarker();
136 }
137 
138 
140 {
141  wxString msg;
142 
143  aList.push_back( MSG_PANEL_ITEM( _( "Electronics Rule Check Error" ),
144  GetReporter().GetErrorText(), DARKRED ) );
145 }
146 
147 
149 {
150  return erc_xpm;
151 }
152 
153 
154 void SCH_MARKER::Rotate( wxPoint aPosition )
155 {
156  RotatePoint( &m_Pos, aPosition, 900 );
157 }
158 
159 
160 void SCH_MARKER::MirrorX( int aXaxis_position )
161 {
162  m_Pos.y -= aXaxis_position;
163  m_Pos.y = -m_Pos.y;
164  m_Pos.y += aXaxis_position;
165 }
166 
167 
168 void SCH_MARKER::MirrorY( int aYaxis_position )
169 {
170  m_Pos.x -= aYaxis_position;
171  m_Pos.x = -m_Pos.x;
172  m_Pos.x += aYaxis_position;
173 }
174 
175 
176 bool SCH_MARKER::IsSelectStateChanged( const wxRect& aRect )
177 {
178  bool previousState = IsSelected();
179 
180  if( aRect.Contains( m_Pos ) )
181  SetFlags( SELECTED );
182  else
183  ClearFlags( SELECTED );
184 
185  return previousState != IsSelected();
186 }
187 
188 
189 bool SCH_MARKER::HitTest( const wxPoint& aPosition, int aAccuracy ) const
190 {
191  return HitTestMarker( aPosition );
192 }
193 
void MirrorX(int aXaxis_position) override
Function MirrorX mirrors item relative to the X axis about aXaxis_position.
Definition: sch_marker.cpp:160
EDA_RECT const GetBoundingBox() const override
Function GetBoundingBox returns the orthogonal, bounding box of this object for display purposes...
Definition: sch_marker.cpp:133
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:38
const wxPoint & GetPos() const
Function GetPos returns the position of this MARKER, const.
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:87
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:189
wxString GetErrorText() const
Function GetErrorText returns the string form of a drc error code.
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:414
wxPoint m_Pos
position of the marker
void GetMsgPanelInfo(std::vector< MSG_PANEL_ITEM > &aList) override
Function GetMsgPanelInfo populates aList of MSG_PANEL_ITEM objects with it's internal state for displ...
Definition: sch_marker.cpp:139
wxString GetMainText() const
acces to A and B texts
bool IsSelected() const
Definition: base_struct.h:235
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
void MirrorY(int aYaxis_position) override
Function MirrorY mirrors item relative to the Y axis about aYaxis_position.
Definition: sch_marker.cpp:168
BITMAP_DEF GetMenuImage() const override
Function GetMenuImage returns a pointer to an image to be used in menus.
Definition: sch_marker.cpp:148
#define SELECTED
Definition: base_struct.h:134
MARKER_SEVERITY GetErrorLevel() const
void SetFlags(STATUS_FLAGS aMask)
Definition: base_struct.h:267
GR_DRAWMODE
Drawmode. Compositing mode plus a flag or two.
Definition: gr_basic.h:41
const DRC_ITEM & GetReporter() const
Function GetReporter returns the DRC_ITEM held within this MARKER so that its interface may be used...
Base window classes and related definitions.
COLOR4D m_Color
color
bool Matches(wxFindReplaceData &aSearchData, void *aAuxData, wxPoint *aFindLocation) override
Function Matches, virtual from the base class EDA_ITEM Compare DRC marker main and auxiliary text aga...
Definition: sch_marker.cpp:109
wxString GetAuxiliaryText() const
void Rotate(wxPoint aPosition) override
Function Rotate rotates the item around aPosition 90 degrees in the clockwise direction.
Definition: sch_marker.cpp:154
EDA_ITEM * Clone() const override
Function Clone creates a duplicate of this item with linked list members set to NULL.
Definition: sch_marker.cpp:58
Class EDA_RECT handles the component boundary box.
Class EDA_ITEM is a base class for most all the KiCad significant classes, used in schematics and boa...
Definition: base_struct.h:165
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:268
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:176
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...
bool Save(FILE *aFile) const override
Function Save (do nothing : markers are no more saved in files ) writes the data structures for this ...
Definition: sch_marker.cpp:81
Class COLOR4D is the color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:39