KiCad PCB EDA Suite
class_marker_pcb.cpp
Go to the documentation of this file.
1 
6 /*
7  * This program source code file is part of KiCad, a free EDA CAD application.
8  *
9  * Copyright (C) 2012 Jean-Pierre Charras, jean-pierre.charras@ujf-grenoble.fr
10  * Copyright (C) 2012 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
11  * Copyright (C) 1992-2012 KiCad Developers, see AUTHORS.txt for contributors.
12  *
13  * This program is free software; you can redistribute it and/or
14  * modify it under the terms of the GNU General Public License
15  * as published by the Free Software Foundation; either version 2
16  * of the License, or (at your option) any later version.
17  *
18  * This program is distributed in the hope that it will be useful,
19  * but WITHOUT ANY WARRANTY; without even the implied warranty of
20  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21  * GNU General Public License for more details.
22  *
23  * You should have received a copy of the GNU General Public License
24  * along with this program; if not, you may find one here:
25  * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
26  * or you may search the http://www.gnu.org website for the version 2 license,
27  * or you may write to the Free Software Foundation, Inc.,
28  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
29  */
30 
31 #include <fctsys.h>
32 #include <gr_basic.h>
33 #include <class_drawpanel.h>
34 #include <trigo.h>
35 #include <msgpanel.h>
36 #include <bitmaps.h>
37 
38 #include <pcbnew.h>
39 #include <class_marker_pcb.h>
41 
42 
44 #define SCALING_FACTOR Mils2iu( 3 )
45 
46 
48  BOARD_ITEM( aParent, PCB_MARKER_T ),
49  MARKER_BASE(), m_item( NULL )
50 {
51  m_Color = WHITE;
53 }
54 
55 
56 MARKER_PCB::MARKER_PCB( int aErrorCode, const wxPoint& aMarkerPos,
57  const wxString& aText, const wxPoint& aPos,
58  const wxString& bText, const wxPoint& bPos ) :
59  BOARD_ITEM( NULL, PCB_MARKER_T ), // parent set during BOARD::Add()
60  MARKER_BASE( aErrorCode, aMarkerPos, aText, aPos, bText, bPos ), m_item( NULL )
61 {
62  m_Color = WHITE;
64 }
65 
66 MARKER_PCB::MARKER_PCB( int aErrorCode, const wxPoint& aMarkerPos,
67  const wxString& aText, const wxPoint& aPos ) :
68  BOARD_ITEM( NULL, PCB_MARKER_T ), // parent set during BOARD::Add()
69  MARKER_BASE( aErrorCode, aMarkerPos, aText, aPos ), m_item( NULL )
70 {
71  m_Color = WHITE;
73 }
74 
75 
76 /* destructor */
78 {
79 }
80 
81 /* tests to see if this object is on the given layer.
82  * DRC markers are not really on a copper layer, but
83  * MARKER_PCB::IsOnCopperLayer return true if aLayer is a cooper layer,
84  * because this test is often used to locad a marker
85  * param aLayer The layer to test for.
86  * return bool - true if on given layer, else false.
87  */
88 bool MARKER_PCB::IsOnLayer( PCB_LAYER_ID aLayer ) const
89 {
90  return IsCopperLayer( aLayer );
91 }
92 
93 void MARKER_PCB::GetMsgPanelInfo( std::vector< MSG_PANEL_ITEM >& aList )
94 {
95  const DRC_ITEM& rpt = m_drc;
96 
97  aList.push_back( MSG_PANEL_ITEM( _( "Type" ), _( "Marker" ), DARKCYAN ) );
98 
99  wxString errorTxt;
100 
101  errorTxt.Printf( _( "ErrType (%d)- %s:" ),
102  rpt.GetErrorCode(),
103  GetChars( rpt.GetErrorText() ) );
104 
105  aList.push_back( MSG_PANEL_ITEM( errorTxt, wxEmptyString, RED ) );
106 
107  wxString txtA;
108  txtA << DRC_ITEM::ShowCoord( rpt.GetPointA() ) << wxT( ": " ) << rpt.GetTextA();
109 
110  wxString txtB;
111 
112  if ( rpt.HasSecondItem() )
113  txtB << DRC_ITEM::ShowCoord( rpt.GetPointB() ) << wxT( ": " ) << rpt.GetTextB();
114 
115  aList.push_back( MSG_PANEL_ITEM( txtA, txtB, DARKBROWN ) );
116 }
117 
118 
119 void MARKER_PCB::Rotate(const wxPoint& aRotCentre, double aAngle)
120 {
121  RotatePoint( &m_Pos, aRotCentre, aAngle );
122 }
123 
124 
125 void MARKER_PCB::Flip(const wxPoint& aCentre )
126 {
127  m_Pos.y = aCentre.y - (m_Pos.y - aCentre.y);
128 }
129 
130 
132 {
133  wxString text;
134  text.Printf( _( "Marker @(%d,%d)" ), GetPos().x, GetPos().y );
135 
136  return text;
137 }
138 
139 
141 {
142  return drc_xpm;
143 }
144 
145 
146 void MARKER_PCB::ViewGetLayers( int aLayers[], int& aCount ) const
147 {
148  aCount = 1;
149  aLayers[0] = LAYER_DRC;
150 }
151 
153 {
154  return EDA_RECT( m_Pos, wxSize( 1300000, 1300000 ) );
155 }
const EDA_RECT GetBoundingBox() const override
Function GetBoundingBox returns the orthogonal, bounding box of this object for display purposes...
PNG memory record (file in memory).
Definition: bitmap_types.h:41
Class DRC_ITEM is a holder for a DRC (in Pcbnew) or ERC (in Eeschema) error item. ...
Definition: drc_item.h:45
const wxPoint & GetPos() const
Function GetPos returns the position of this MARKER, const.
Definition: marker_base.h:116
void Flip(const wxPoint &aCentre) override
Function Flip Flip this object, i.e.
bool HasSecondItem() const
Definition: drc_item.h:141
Class BOARD_ITEM is a base class for any item which can be embedded within the BOARD container class...
wxString GetErrorText() const
Function GetErrorText returns the string form of a drc error code.
Definition: drc_item.cpp:38
int GetErrorCode() const
Function GetErrorCode returns the error code.
Definition: drc_item.h:239
BITMAP_DEF GetMenuImage() const override
Function GetMenuImage returns a pointer to an image to be used in menus.
wxPoint m_Pos
position of the marker
Definition: marker_base.h:53
const wxPoint & GetPointB() const
Definition: drc_item.h:268
void RotatePoint(int *pX, int *pY, double angle)
Definition: trigo.cpp:216
const BOARD_ITEM * m_item
Pointer to BOARD_ITEM that causes DRC error.
bool IsOnLayer(PCB_LAYER_ID aLayer) const override
Function IsOnLayer tests to see if this object is on the given layer.
Markers used to show a drc problem on boards.
PCB_LAYER_ID
A quick note on layer IDs:
#define SCALING_FACTOR
Adjust the actual size of markers, when using default shape.
COLOR4D m_Color
color
Definition: marker_base.h:58
int m_ScalingFactor
Scaling factor for m_Size and m_Corners (can set the physical size.
Definition: marker_base.h:62
Definition: colors.h:60
MARKER_PCB(BOARD_ITEM *aParent)
const wxString & GetTextA() const
Definition: drc_item.h:250
class MARKER_PCB, a marker used to show something
Definition: typeinfo.h:99
static const wxChar * GetChars(const wxString &s)
Function GetChars returns a wxChar* to the actual wxChar* data within a wxString, and is helpful for ...
Definition: macros.h:92
void Rotate(const wxPoint &aRotCentre, double aAngle) override
Function Rotate Rotate this object.
const wxPoint & GetPointA() const
Definition: drc_item.h:262
wxString GetSelectMenuText() const override
Function GetSelectMenuText returns the text to display to be used in the selection clarification cont...
Board layer functions and definitions.
Class EDA_RECT handles the component boundary box.
Definition: eda_rect.h:44
Definition: colors.h:49
bool IsCopperLayer(LAYER_NUM aLayerId)
Function IsCopperLayer tests whether a layer is a copper layer.
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...
void ViewGetLayers(int aLayers[], int &aCount) const override
Function ViewGetLayers() Returns the all the layers within the VIEW the object is painted on...
Class EDA_MSG_ITEM is used EDA_MSG_PANEL as the item type for displaying messages.
Definition: msgpanel.h:53
const wxString & GetTextB() const
Definition: drc_item.h:256
Message panel definition file.
static wxString ShowCoord(const wxPoint &aPos)
Function ShowCoord formats a coordinate or position to text.
Definition: drc_item.cpp:148
DRC_ITEM m_drc
Definition: marker_base.h:64