KiCad PCB EDA Suite
cleanup_item.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) 2020 KiCad Developers, see change_log.txt for contributors.
5  *
6  * This program is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License
8  * as published by the Free Software Foundation; either version 2
9  * of the License, or (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, you may find one here:
18  * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
19  * or you may search the http://www.gnu.org website for the version 2 license,
20  * or you may write to the Free Software Foundation, Inc.,
21  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
22  */
23 
24 
25 #include <fctsys.h>
26 #include <cleanup_item.h>
27 #include <pcb_base_frame.h>
28 
29 
30 CLEANUP_ITEM::CLEANUP_ITEM( int aErrorCode )
31 {
32  m_errorCode = aErrorCode;
33  m_errorTitle = GetErrorText( aErrorCode );
34 }
35 
36 
37 wxString CLEANUP_ITEM::GetErrorText( int aCode, bool aTranslate ) const
38 {
39  wxString msg;
40 
41  if( aCode < 0 )
42  aCode = m_errorCode;
43 
44  switch( aCode )
45  {
46  // For cleanup tracks and vias:
47  case CLEANUP_SHORT: msg = _HKI( "Remove track shorting two nets" ); break;
48  case CLEANUP_REDUNDANT_VIA: msg = _HKI( "Remove redundant via" ); break;
49  case CLEANUP_DUPLICATE_TRACK: msg = _HKI( "Remove duplicate track" ); break;
50  case CLEANUP_MERGE_TRACKS: msg = _HKI( "Merge co-linear tracks" ); break;
51  case CLEANUP_DANGLING_TRACK: msg = _HKI( "Remove dangling track" ); break;
52  case CLEANUP_DANGLING_VIA: msg = _HKI( "Remove dangling via" ); break;
53  case CLEANUP_ZERO_LENGTH_TRACK: msg = _HKI( "Remove zero-length track" ); break;
54  case CLEANUP_TRACK_IN_PAD: msg = _HKI( "Remove track inside pad" ); break;
55 
56  // For cleanup graphics:
57  case CLEANUP_NULL_GRAPHIC: msg = _HKI( "Remove zero-size graphic" ); break;
58  case CLEANUP_DUPLICATE_GRAPHIC: msg = _HKI( "Remove duplicated graphic" ); break;
59  case CLEANUP_LINES_TO_RECT: msg = _HKI( "Convert lines to rectangle" ); break;
60 
61  default:
62  wxFAIL_MSG( "Missing cleanup item description" );
63  msg = _HKI( "Unknown cleanup action" );
64  break;
65  }
66 
67  if( aTranslate )
68  return wxGetTranslation( msg );
69  else
70  return msg;
71 }
72 
73 
CLEANUP_ITEM(int aErrorCode)
wxString GetErrorText() const
Definition: rc_item.h:165
Classes used in Pcbnew, CvPcb and GerbView.
int m_errorCode
Definition: rc_item.h:76
#define _HKI(x)
wxString m_errorTitle
The string describing the type of error.
Definition: rc_item.h:78