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 <wxstruct.h>
35 #include <trigo.h>
36 #include <msgpanel.h>
37 #include <bitmaps.h>
38 
39 #include <pcbnew.h>
40 #include <class_marker_pcb.h>
42 
43 
45 #define SCALING_FACTOR Mils2iu( 3 )
46 
47 
49  BOARD_ITEM( aParent, PCB_MARKER_T ),
50  MARKER_BASE(), m_item( NULL )
51 {
52  m_Color = WHITE;
54 }
55 
56 
57 MARKER_PCB::MARKER_PCB( int aErrorCode, const wxPoint& aMarkerPos,
58  const wxString& aText, const wxPoint& aPos,
59  const wxString& bText, const wxPoint& bPos ) :
60  BOARD_ITEM( NULL, PCB_MARKER_T ), // parent set during BOARD::Add()
61  MARKER_BASE( aErrorCode, aMarkerPos, aText, aPos, bText, bPos ), m_item( NULL )
62 {
63  m_Color = WHITE;
65 }
66 
67 MARKER_PCB::MARKER_PCB( int aErrorCode, const wxPoint& aMarkerPos,
68  const wxString& aText, const wxPoint& aPos ) :
69  BOARD_ITEM( NULL, PCB_MARKER_T ), // parent set during BOARD::Add()
70  MARKER_BASE( aErrorCode, aMarkerPos, aText, aPos ), m_item( NULL )
71 {
72  m_Color = WHITE;
74 }
75 
76 
77 /* destructor */
79 {
80 }
81 
82 /* tests to see if this object is on the given layer.
83  * DRC markers are not really on a copper layer, but
84  * MARKER_PCB::IsOnCopperLayer return true if aLayer is a cooper layer,
85  * because this test is often used to locad a marker
86  * param aLayer The layer to test for.
87  * return bool - true if on given layer, else false.
88  */
89 bool MARKER_PCB::IsOnLayer( LAYER_ID aLayer ) const
90 {
91  return IsCopperLayer( aLayer );
92 }
93 
94 void MARKER_PCB::GetMsgPanelInfo( std::vector< MSG_PANEL_ITEM >& aList )
95 {
96  const DRC_ITEM& rpt = m_drc;
97 
98  aList.push_back( MSG_PANEL_ITEM( _( "Type" ), _( "Marker" ), DARKCYAN ) );
99 
100  wxString errorTxt;
101 
102  errorTxt.Printf( _( "ErrType (%d)- %s:" ),
103  rpt.GetErrorCode(),
104  GetChars( rpt.GetErrorText() ) );
105 
106  aList.push_back( MSG_PANEL_ITEM( errorTxt, wxEmptyString, RED ) );
107 
108  wxString txtA;
109  txtA << DRC_ITEM::ShowCoord( rpt.GetPointA() ) << wxT( ": " ) << rpt.GetTextA();
110 
111  wxString txtB;
112 
113  if ( rpt.HasSecondItem() )
114  txtB << DRC_ITEM::ShowCoord( rpt.GetPointB() ) << wxT( ": " ) << rpt.GetTextB();
115 
116  aList.push_back( MSG_PANEL_ITEM( txtA, txtB, DARKBROWN ) );
117 }
118 
119 
120 void MARKER_PCB::Rotate(const wxPoint& aRotCentre, double aAngle)
121 {
122  RotatePoint( &m_Pos, aRotCentre, aAngle );
123 }
124 
125 
126 void MARKER_PCB::Flip(const wxPoint& aCentre )
127 {
128  m_Pos.y = aCentre.y - (m_Pos.y - aCentre.y);
129 }
130 
131 
133 {
134  wxString text;
135  text.Printf( _( "Marker @(%d,%d)" ), GetPos().x, GetPos().y );
136 
137  return text;
138 }
139 
140 
142 {
143  return drc_xpm;
144 }
145 
146 
147 void MARKER_PCB::ViewGetLayers( int aLayers[], int& aCount ) const
148 {
149  aCount = 1;
150  aLayers[0] = ITEM_GAL_LAYER( DRC_VISIBLE );
151 }
152 
154 {
155  return EDA_RECT( m_Pos, wxSize( 1300000, 1300000 ) );
156 }
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:38
Class DRC_ITEM is a holder for a DRC (in Pcbnew) or ERC (in Eeschema) error item. ...
const wxPoint & GetPos() const
Function GetPos returns the position of this MARKER, const.
void Flip(const wxPoint &aCentre) override
Function Flip Flip this object, i.e.
bool HasSecondItem() const
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.
int GetErrorCode() const
Function GetErrorCode returns the error code.
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
const wxPoint & GetPointB() const
bool IsOnLayer(LAYER_ID aLayer) const override
Function IsOnLayer tests to see if this object is on the given layer.
void RotatePoint(int *pX, int *pY, double angle)
Definition: trigo.cpp:317
Markers used to show a drc problem on boards.
Base window classes and related definitions.
#define SCALING_FACTOR
Adjust the actual size of markers, when using default shape.
COLOR4D m_Color
color
int m_ScalingFactor
Scaling factor for m_Size and m_Corners (can set the physical size.
Definition: colors.h:60
MARKER_PCB(BOARD_ITEM *aParent)
const wxString & GetTextA() const
#define ITEM_GAL_LAYER(layer)
macro for obtaining layer number for specific item (eg. pad or text)
class MARKER_PCB, a marker used to show something
Definition: typeinfo.h:111
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
wxString GetSelectMenuText() const override
Function GetSelectMenuText returns the text to display to be used in the selection clarification cont...
Board layer functions and definitions.
LAYER_ID
Enum LAYER_ID is the set of PCB layers.
Class EDA_RECT handles the component boundary box.
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's internal state for displ...
void ViewGetLayers(int aLayers[], int &aCount) const override
Class EDA_MSG_ITEM is used EDA_MSG_PANEL as the item type for displaying messages.
Definition: msgpanel.h:53
const wxString & GetTextB() const
Message panel definition file.
static wxString ShowCoord(const wxPoint &aPos)
Function ShowCoord formats a coordinate or position to text.