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 <erc_settings.h>
32 #include <sch_marker.h>
33 #include <schematic.h>
34 #include <widgets/ui_common.h>
35 #include <pgm_base.h>
38 #include <erc_item.h>
39 
41 #define SCALING_FACTOR Millimeter2iu( 0.15 )
42 
43 
44 SCH_MARKER::SCH_MARKER( ERC_ITEM* aItem, const wxPoint& aPos ) :
45  SCH_ITEM( nullptr, SCH_MARKER_T ),
46  MARKER_BASE( SCALING_FACTOR, aItem, MARKER_BASE::MARKER_ERC )
47 {
48  if( m_rcItem )
49  m_rcItem->SetParent( this );
50 
51  m_Pos = aPos;
52 }
53 
54 
56 {
57  return new SCH_MARKER( *this );
58 }
59 
60 
62 {
63  std::swap( *((SCH_MARKER*) this), *((SCH_MARKER*) aItem ) );
64 }
65 
66 
67 #if defined(DEBUG)
68 
69 void SCH_MARKER::Show( int nestLevel, std::ostream& os ) const
70 {
71  // for now, make it look like XML:
72  NestedSpace( nestLevel, os ) << '<' << GetClass().Lower().mb_str() << GetPos() << "/>\n";
73 }
74 
75 #endif
76 
77 
78 void SCH_MARKER::ViewGetLayers( int aLayers[], int& aCount ) const
79 {
80  aCount = 2;
81 
82  wxCHECK_RET( Schematic(), "No SCHEMATIC set for SCH_MARKER!" );
83 
84  switch( Schematic()->ErcSettings().GetSeverity( m_rcItem->GetErrorCode() ) )
85  {
86  default:
87  case SEVERITY::RPT_SEVERITY_ERROR: aLayers[0] = LAYER_ERC_ERR; break;
88  case SEVERITY::RPT_SEVERITY_WARNING: aLayers[0] = LAYER_ERC_WARN; break;
89  }
90 
91  aLayers[1] = LAYER_SELECTION_SHADOWS;
92 }
93 
94 
96 {
97  if( IsExcluded() )
98  return LAYER_HIDDEN;
99 
100  wxCHECK_MSG( Schematic(), LAYER_ERC_ERR, "No SCHEMATIC set for SCH_MARKER!" );
101 
102  switch( Schematic()->ErcSettings().GetSeverity( m_rcItem->GetErrorCode() ) )
103  {
104  default:
107  }
108 }
109 
110 
112 {
113  COLOR_SETTINGS* colors = Pgm().GetSettingsManager().GetColorSettings();
114  return colors->GetColor( GetColorLayer() );
115 }
116 
117 
118 void SCH_MARKER::Print( RENDER_SETTINGS* aSettings, const wxPoint& aOffset )
119 {
120  PrintMarker( aSettings, aOffset );
121 }
122 
123 
124 bool SCH_MARKER::Matches( wxFindReplaceData& aSearchData, void* aAuxData )
125 {
126  return SCH_ITEM::Matches( m_rcItem->GetErrorMessage(), aSearchData );
127 }
128 
129 
131 {
132  return GetBoundingBoxMarker();
133 }
134 
135 
137 {
138  aList.push_back( MSG_PANEL_ITEM( _( "Electronics Rule Check Error" ),
140 }
141 
142 
144 {
145  return erc_xpm;
146 }
147 
148 
149 void SCH_MARKER::Rotate( wxPoint aPosition )
150 {
151  RotatePoint( &m_Pos, aPosition, 900 );
152 }
153 
154 
155 void SCH_MARKER::MirrorX( int aXaxis_position )
156 {
157  m_Pos.y -= aXaxis_position;
158  m_Pos.y = -m_Pos.y;
159  m_Pos.y += aXaxis_position;
160 }
161 
162 
163 void SCH_MARKER::MirrorY( int aYaxis_position )
164 {
165  m_Pos.x -= aYaxis_position;
166  m_Pos.x = -m_Pos.x;
167  m_Pos.x += aYaxis_position;
168 }
169 
170 
171 bool SCH_MARKER::HitTest( const wxPoint& aPosition, int aAccuracy ) const
172 {
173  return HitTestMarker( aPosition, aAccuracy );
174 }
void GetMsgPanelInfo(EDA_DRAW_FRAME *aFrame, 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:136
const wxPoint & GetPos() const
Function GetPos.
Definition: marker_base.h:98
void MirrorX(int aXaxis_position) override
Mirror item relative to the X axis about aXaxis_position.
Definition: sch_marker.cpp:155
EDA_RECT const GetBoundingBox() const override
Function GetBoundingBox returns the orthogonal, bounding box of this object for display purposes.
Definition: sch_marker.cpp:130
KIWAY Kiway & Pgm(), KFCTL_STANDALONE
The global Program "get" accessor.
Definition: single_top.cpp:104
PNG memory record (file in memory).
Definition: bitmap_def.h:29
SCH_LAYER_ID GetColorLayer() const
Definition: sch_marker.cpp:95
void SwapData(SCH_ITEM *aItem) override
Swap the internal data structures aItem with the schematic item.
Definition: sch_marker.cpp:61
RENDER_SETTINGS Contains all the knowledge about how graphical objects are drawn on any output surfac...
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:41
wxPoint m_Pos
position of the marker
Definition: marker_base.h:59
SCHEMATIC * Schematic() const
Searches the item hierarchy to find a SCHEMATIC.
Definition: sch_item.cpp:116
void RotatePoint(int *pX, int *pY, double angle)
Definition: trigo.cpp:208
void SetParent(MARKER_BASE *aMarker)
Definition: rc_item.h:144
The base class for create windows for drawing purpose.
const BITMAP_OPAQUE erc_xpm[1]
EDA_RECT GetBoundingBoxMarker() const
Function GetBoundingBoxMarker returns the orthogonal, bounding box of this object for display purpose...
void MirrorY(int aYaxis_position) override
Mirror item relative to the Y axis about aYaxis_position.
Definition: sch_marker.cpp:163
BITMAP_DEF GetMenuImage() const override
Function GetMenuImage returns a pointer to an image to be used in menus.
Definition: sch_marker.cpp:143
bool Matches(wxFindReplaceData &aSearchData, void *aAuxDat) override
Compare DRC marker main and auxiliary text against search string.
Definition: sch_marker.cpp:124
RC_ITEM * m_rcItem
Definition: marker_base.h:64
bool HitTestMarker(const wxPoint &aHitPosition, int aAccuracy) const
Tests if the given wxPoint is within the bounds of this object.
Definition: marker_base.cpp:92
void Print(RENDER_SETTINGS *aSettings, const wxPoint &aOffset) override
Print a schematic item.
Definition: sch_marker.cpp:118
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:171
void PrintMarker(RENDER_SETTINGS *aSettings, const wxPoint &aOffset)
Function PrintMarker Prints the shape is the polygon defined in m_Corners (array of wxPoints).
int GetErrorCode() const
Definition: rc_item.h:156
void ViewGetLayers(int aLayers[], int &aCount) const override
Return the layers the item is drawn on (which may be more than its "home" layer)
Definition: sch_marker.cpp:78
Functions to provide common constants and other functions to assist in making a consistent UI.
bool IsExcluded() const
Definition: marker_base.h:108
SCH_LAYER_ID
Eeschema drawing layers.
SCH_MARKER(ERC_ITEM *aItem, const wxPoint &aPos)
Definition: sch_marker.cpp:44
void Rotate(wxPoint aPosition) override
Rotate the item around aPosition 90 degrees in the clockwise direction.
Definition: sch_marker.cpp:149
see class PGM_BASE
KIGFX::COLOR4D getColor() const override
Definition: sch_marker.cpp:111
#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:55
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:159
std::vector< MSG_PANEL_ITEM > MSG_PANEL_ITEMS
Definition: msgpanel.h:102
Color settings are a bit different than most of the settings objects in that there can be more than o...
wxString GetClass() const override
Function GetClass returns the class name.
Definition: sch_marker.h:45
EDA_MSG_ITEM is used EDA_MSG_PANEL as the item type for displaying messages.
Definition: msgpanel.h:53
Message panel definition file.
virtual bool Matches(wxFindReplaceData &aSearchData, void *aAuxData)
Function Matches compares the item against the search criteria in aSearchData.
Definition: base_struct.h:457
Base class for any item which can be embedded within the SCHEMATIC container class,...
Definition: sch_item.h:187
static VRML_COLOR colors[VRML_COLOR_LAST]
virtual wxString GetErrorMessage() const
Function GetErrorMessage returns the error message of a RC_ITEM.
Definition: rc_item.cpp:36
COLOR4D is the color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:99