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 
32 #include <sch_marker.h>
33 
35 #define SCALING_FACTOR Millimeter2iu( 0.1 )
36 
37 
39 {
40 }
41 
42 
43 SCH_MARKER::SCH_MARKER( const wxPoint& pos, const wxString& text ) :
45  MARKER_BASE( 0, pos, text, pos, SCALING_FACTOR )
46 {
47 }
48 
49 
51 {
52  return new SCH_MARKER( *this );
53 }
54 
55 
57 {
58  std::swap( *((SCH_MARKER*) this), *((SCH_MARKER*) aItem ) );
59 }
60 
61 
62 #if defined(DEBUG)
63 
64 void SCH_MARKER::Show( int nestLevel, std::ostream& os ) const
65 {
66  // for now, make it look like XML:
67  NestedSpace( nestLevel, os ) << '<' << GetClass().Lower().mb_str() << GetPos() << "/>\n";
68 }
69 
70 #endif
71 
72 
73 void SCH_MARKER::Print( wxDC* aDC, const wxPoint& aOffset )
74 {
75  COLOR4D tmp = m_Color;
76 
78  {
81  }
82 
83  PrintMarker( aDC, aOffset );
84  m_Color = tmp;
85 }
86 
87 
88 bool SCH_MARKER::Matches( wxFindReplaceData& aSearchData, void* aAuxData )
89 {
90  return SCH_ITEM::Matches( m_drc.GetErrorText(), aSearchData )
91  || SCH_ITEM::Matches( m_drc.GetMainText(), aSearchData )
92  || SCH_ITEM::Matches( m_drc.GetAuxiliaryText(), aSearchData );
93 }
94 
95 
96 void SCH_MARKER::ViewGetLayers( int aLayers[], int& aCount ) const
97 {
98  aCount = 2;
100  aLayers[1] = LAYER_SELECTION_SHADOWS;
101 }
102 
103 
105 {
106  return GetBoundingBoxMarker();
107 }
108 
109 
111 {
112  aList.push_back( MSG_PANEL_ITEM( _( "Electronics Rule Check Error" ),
113  GetReporter().GetErrorText(), DARKRED ) );
114 }
115 
116 
118 {
119  return erc_xpm;
120 }
121 
122 
123 void SCH_MARKER::Rotate( wxPoint aPosition )
124 {
125  RotatePoint( &m_Pos, aPosition, 900 );
126 }
127 
128 
129 void SCH_MARKER::MirrorX( int aXaxis_position )
130 {
131  m_Pos.y -= aXaxis_position;
132  m_Pos.y = -m_Pos.y;
133  m_Pos.y += aXaxis_position;
134 }
135 
136 
137 void SCH_MARKER::MirrorY( int aYaxis_position )
138 {
139  m_Pos.x -= aYaxis_position;
140  m_Pos.x = -m_Pos.x;
141  m_Pos.x += aYaxis_position;
142 }
143 
144 
145 bool SCH_MARKER::HitTest( const wxPoint& aPosition, int aAccuracy ) const
146 {
147  return HitTestMarker( aPosition, aAccuracy );
148 }
EDA_UNITS
Definition: common.h:72
const wxPoint & GetPos() const
Function GetPos.
Definition: marker_base.h:152
void MirrorX(int aXaxis_position) override
Function MirrorX mirrors item relative to the X axis about aXaxis_position.
Definition: sch_marker.cpp:129
EDA_RECT const GetBoundingBox() const override
Function GetBoundingBox returns the orthogonal, bounding box of this object for display purposes.
Definition: sch_marker.cpp:104
wxString GetErrorText() const
Function GetErrorText returns the string form of a drc error code.
MARKER_SEVERITY m_ErrorLevel
Specify the severity of the error.
Definition: marker_base.h:60
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:241
PNG memory record (file in memory).
Definition: bitmap_def.h:29
void SwapData(SCH_ITEM *aItem) override
Function SwapData swap the internal data structures aItem with the schematic item.
Definition: sch_marker.cpp:56
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:35
MARKER_SEVERITY GetErrorLevel() const
Definition: marker_base.h:174
wxPoint m_Pos
position of the marker
Definition: marker_base.h:54
wxString GetMainText() const
Access to A and B texts.
Definition: drc_item.h:174
void RotatePoint(int *pX, int *pY, double angle)
Definition: trigo.cpp:208
COLOR4D GetLayerColor(SCH_LAYER_ID aLayer)
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:137
BITMAP_DEF GetMenuImage() const override
Function GetMenuImage returns a pointer to an image to be used in menus.
Definition: sch_marker.cpp:117
bool Matches(wxFindReplaceData &aSearchData, void *aAuxDat) override
Compare DRC marker main and auxiliary text against search string.
Definition: sch_marker.cpp:88
bool HitTestMarker(const wxPoint &aHitPosition, int aAccuracy) const
Tests if the given wxPoint is within the bounds of this object.
#define NULL
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:145
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:96
COLOR4D m_Color
color
Definition: marker_base.h:61
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:123
void Print(wxDC *aDC, const wxPoint &aOffset) override
Function Print Print a schematic item.
Definition: sch_marker.cpp:73
enum TYPEMARKER GetMarkerType() const
Definition: marker_base.h:186
#define _(s)
Definition: 3d_actions.cpp:31
EDA_ITEM * Clone() const override
Function Clone creates a duplicate of this item with linked list members set to NULL.
Definition: sch_marker.cpp:50
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:163
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:46
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:110
virtual bool Matches(wxFindReplaceData &aSearchData, void *aAuxData)
Function Matches compares the item against the search criteria in aSearchData.
Definition: base_struct.h:471
SCH_ITEM is a base class for any item which can be embedded within the SCHEMATIC container class,...
Definition: sch_item.h:136
wxString GetAuxiliaryText() const
Definition: drc_item.h:175
DRC_ITEM m_drc
Definition: marker_base.h:64
COLOR4D is the color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:39