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-2019 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 
25 #include <fctsys.h>
26 #include <sch_draw_panel.h>
27 #include <trigo.h>
28 #include <msgpanel.h>
29 #include <bitmaps.h>
30 #include <base_units.h>
31 #include <sch_marker.h>
32 #include <widgets/ui_common.h>
33 #include <pgm_base.h>
36 #include <erc_item.h>
37 
39 #define SCALING_FACTOR Millimeter2iu( 0.1 )
40 
41 
43  SCH_ITEM( nullptr, SCH_MARKER_T ),
44  MARKER_BASE( SCALING_FACTOR, new ERC_ITEM(), aType )
45 {
46 }
47 
48 
50 {
51  return new SCH_MARKER( *this );
52 }
53 
54 
56 {
57  std::swap( *((SCH_MARKER*) this), *((SCH_MARKER*) aItem ) );
58 }
59 
60 
61 #if defined(DEBUG)
62 
63 void SCH_MARKER::Show( int nestLevel, std::ostream& os ) const
64 {
65  // for now, make it look like XML:
66  NestedSpace( nestLevel, os ) << '<' << GetClass().Lower().mb_str() << GetPos() << "/>\n";
67 }
68 
69 #endif
70 
71 
72 void SCH_MARKER::ViewGetLayers( int aLayers[], int& aCount ) const
73 {
74  aCount = 2;
75 
77  {
78  default:
79  case SEVERITY::RPT_SEVERITY_ERROR: aLayers[0] = LAYER_ERC_ERR; break;
80  case SEVERITY::RPT_SEVERITY_WARNING: aLayers[0] = LAYER_ERC_WARN; break;
81  }
82 
83  aLayers[1] = LAYER_SELECTION_SHADOWS;
84 }
85 
86 
88 {
89  if( IsExcluded() )
90  return LAYER_HIDDEN;
91 
93  {
94  default:
97  }
98 }
99 
100 
102 {
103  COLOR_SETTINGS* colors = Pgm().GetSettingsManager().GetColorSettings();
104  return colors->GetColor( GetColorLayer() );
105 }
106 
107 
108 void SCH_MARKER::Print( wxDC* aDC, const wxPoint& aOffset )
109 {
110  PrintMarker( aDC, aOffset );
111 }
112 
113 
114 bool SCH_MARKER::Matches( wxFindReplaceData& aSearchData, void* aAuxData )
115 {
116  return SCH_ITEM::Matches( m_rcItem->GetErrorText(), aSearchData )
117  || SCH_ITEM::Matches( m_rcItem->GetMainText(), aSearchData )
118  || SCH_ITEM::Matches( m_rcItem->GetAuxText(), aSearchData );
119 }
120 
121 
123 {
124  return GetBoundingBoxMarker();
125 }
126 
127 
129 {
130  aList.push_back( MSG_PANEL_ITEM( _( "Electronics Rule Check Error" ),
131  m_rcItem->GetErrorText(), DARKRED ) );
132 }
133 
134 
136 {
137  return erc_xpm;
138 }
139 
140 
141 void SCH_MARKER::Rotate( wxPoint aPosition )
142 {
143  RotatePoint( &m_Pos, aPosition, 900 );
144 }
145 
146 
147 void SCH_MARKER::MirrorX( int aXaxis_position )
148 {
149  m_Pos.y -= aXaxis_position;
150  m_Pos.y = -m_Pos.y;
151  m_Pos.y += aXaxis_position;
152 }
153 
154 
155 void SCH_MARKER::MirrorY( int aYaxis_position )
156 {
157  m_Pos.x -= aYaxis_position;
158  m_Pos.x = -m_Pos.x;
159  m_Pos.x += aYaxis_position;
160 }
161 
162 
163 bool SCH_MARKER::HitTest( const wxPoint& aPosition, int aAccuracy ) const
164 {
165  return HitTestMarker( aPosition, aAccuracy );
166 }
EDA_UNITS
Definition: common.h:184
const wxPoint & GetPos() const
Function GetPos.
Definition: marker_base.h:90
void MirrorX(int aXaxis_position) override
Function MirrorX mirrors item relative to the X axis about aXaxis_position.
Definition: sch_marker.cpp:147
EDA_RECT const GetBoundingBox() const override
Function GetBoundingBox returns the orthogonal, bounding box of this object for display purposes.
Definition: sch_marker.cpp:122
KIWAY Kiway & Pgm(), KFCTL_STANDALONE
The global Program "get" accessor.
Definition: single_top.cpp:103
PNG memory record (file in memory).
Definition: bitmap_def.h:29
SCH_LAYER_ID GetColorLayer() const
Definition: sch_marker.cpp:87
void SwapData(SCH_ITEM *aItem) override
Function SwapData swap the internal data structures aItem with the schematic item.
Definition: sch_marker.cpp:55
Implementation of conversion functions that require both schematic and board internal units.
#define SCALING_FACTOR
Factor to convert the maker unit shape to internal units:
Definition: sch_marker.cpp:39
wxPoint m_Pos
position of the marker
Definition: marker_base.h:51
wxString GetMainText() const
Definition: rc_item.h:260
void RotatePoint(int *pX, int *pY, double angle)
Definition: trigo.cpp:208
const BITMAP_OPAQUE erc_xpm[1]
Definition: colors.h:54
EDA_RECT GetBoundingBoxMarker() const
Function GetBoundingBoxMarker returns the orthogonal, bounding box of this object for display purpose...
void MirrorY(int aYaxis_position) override
Function MirrorY mirrors item relative to the Y axis about aYaxis_position.
Definition: sch_marker.cpp:155
ERC_SETTINGS * g_ErcSettings
This also wants to live in the eventual SCHEMATIC object.
BITMAP_DEF GetMenuImage() const override
Function GetMenuImage returns a pointer to an image to be used in menus.
Definition: sch_marker.cpp:135
bool Matches(wxFindReplaceData &aSearchData, void *aAuxDat) override
Compare DRC marker main and auxiliary text against search string.
Definition: sch_marker.cpp:114
RC_ITEM * m_rcItem
Definition: marker_base.h:56
bool HitTestMarker(const wxPoint &aHitPosition, int aAccuracy) const
Tests if the given wxPoint is within the bounds of this object.
bool HitTest(const wxPoint &aPosition, int aAccuracy=0) const override
Function HitTest tests if aPosition is contained within or on the bounding box of an item.
Definition: sch_marker.cpp:163
wxString GetAuxText() const
Definition: rc_item.h:261
int GetErrorCode() const
Definition: rc_item.h:273
void ViewGetLayers(int aLayers[], int &aCount) const override
Function ViewGetLayers returns the layers the item is drawn on (which may be more than its "home" lay...
Definition: sch_marker.cpp:72
Functions to provide common constants and other functions to assist in making a consistent UI.
bool IsExcluded() const
Definition: marker_base.h:172
SCH_LAYER_ID
Eeschema drawing layers.
virtual wxString GetErrorText() const =0
Function GetErrorText returns the string form of a drc error code.
std::map< int, int > m_Severities
Definition: erc_settings.h:75
void PrintMarker(wxDC *aDC, const wxPoint &aOffset)
Function PrintMarker Prints the shape is the polygon defined in m_Corners (array of wxPoints).
void Rotate(wxPoint aPosition) override
Function Rotate rotates the item around aPosition 90 degrees in the clockwise direction.
Definition: sch_marker.cpp:141
see class PGM_BASE
KIGFX::COLOR4D getColor() const override
Definition: sch_marker.cpp:101
void Print(wxDC *aDC, const wxPoint &aOffset) override
Function Print Print a schematic item.
Definition: sch_marker.cpp:108
#define _(s)
Definition: 3d_actions.cpp:33
EDA_ITEM * Clone() const override
Function Clone creates a duplicate of this item with linked list members set to NULL.
Definition: sch_marker.cpp:49
EDA_RECT handles the component boundary box.
Definition: eda_rect.h:44
EDA_ITEM is a base class for most all the KiCad significant classes, used in schematics and boards.
Definition: base_struct.h:166
std::vector< MSG_PANEL_ITEM > MSG_PANEL_ITEMS
Definition: msgpanel.h:102
wxString GetClass() const override
Function GetClass returns the class name.
Definition: sch_marker.h:44
EDA_MSG_ITEM is used EDA_MSG_PANEL as the item type for displaying messages.
Definition: msgpanel.h:53
Message panel definition file.
void GetMsgPanelInfo(EDA_UNITS aUnits, 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:128
SCH_MARKER(TYPEMARKER aType)
Definition: sch_marker.cpp:42
virtual bool Matches(wxFindReplaceData &aSearchData, void *aAuxData)
Function Matches compares the item against the search criteria in aSearchData.
Definition: base_struct.h:473
SCH_ITEM is a base class for any item which can be embedded within the SCHEMATIC container class,...
Definition: sch_item.h:147
static VRML_COLOR colors[VRML_COLOR_LAST]
COLOR4D is the color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:40