Code cleaning: remove pcbcommon.* which contains nothing really useful. The very few lines of code are moved to a better place.

This commit is contained in:
jean-pierre charras 2016-12-31 12:56:00 +01:00
parent c45cc1de68
commit b8b08dafd6
14 changed files with 56 additions and 134 deletions

View File

@ -328,7 +328,6 @@ set( PCB_COMMON_SRCS
base_screen.cpp
eda_text.cpp
class_page_info.cpp
pcbcommon.cpp
lset.cpp
footprint_info.cpp
../pcbnew/basepcbframe.cpp

View File

@ -1,73 +0,0 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2008 Wayne Stambaugh <stambaughw@verizon.net>
* Copyright (C) 1992-2008 KiCad Developers, see change_log.txt for contributors.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, you may find one here:
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
* or you may search the http://www.gnu.org website for the version 2 license,
* or you may write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
/*
* This file contains some functions used in the PCB
* applications Pcbnew and CvPcb.
*/
#include <fctsys.h>
#include <pgm_base.h>
#include <kiface_i.h>
#include <pcbcommon.h>
#include <class_board.h>
wxString LayerMaskDescribe( const BOARD *aBoard, LSET aMask )
{
// Try the single or no- layer case (easy)
LAYER_ID layer = aMask.ExtractLayer();
switch( (int) layer )
{
case UNSELECTED_LAYER:
return _( "No layers" );
case UNDEFINED_LAYER:
break;
default:
return aBoard->GetLayerName( layer );
}
// Try to be smart and useful, starting with outer copper
// (which are more important than internal ones)
wxString layerInfo;
if( aMask[F_Cu] )
AccumulateDescription( layerInfo, aBoard->GetLayerName( F_Cu ) );
if( aMask[B_Cu] )
AccumulateDescription( layerInfo, aBoard->GetLayerName( B_Cu ) );
if( ( aMask & LSET::InternalCuMask() ).any() )
AccumulateDescription( layerInfo, _("Internal" ) );
if( ( aMask & LSET::AllNonCuMask() ).any() )
AccumulateDescription( layerInfo, _("Non-copper" ) );
return layerInfo;
}

View File

@ -1,7 +1,7 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2015 Jean-Pierre Charras, jp.charras at wanadoo.fr
* Copyright (C) 2016 Jean-Pierre Charras, jp.charras at wanadoo.fr
* Copyright (C) 2015-2016 Wayne Stambaugh <stambaughw@verizon.net>
* Copyright (C) 2007-2016 KiCad Developers, see AUTHORS.txt for contributors.
*
@ -28,7 +28,6 @@
*/
#include <fctsys.h>
#include <pgm_base.h>
#include <common.h>
#include <class_drawpanel.h>
#include <class_draw_panel_gal.h>
@ -39,7 +38,6 @@
#include <wildcards_and_files_ext.h>
#include <lib_id.h>
#include <fp_lib_table.h>
#include <pcbcommon.h>
#include <io_mgr.h>
#include <class_module.h>

View File

@ -34,7 +34,6 @@
#include <pgm_base.h>
#include <wxstruct.h>
#include <confirm.h>
#include <pcbcommon.h>
#include <cvpcb.h>
#include <zones.h>

View File

@ -663,12 +663,6 @@ LAYER_ID FlipLayer( LAYER_ID aLayerId, int aCopperLayersCount = 0 );
*/
LSET FlipLayerMask( LSET aMask, int aCopperLayersCount = 0 );
/**
* Return a string (to be shown to the user) describing a layer mask.
* Useful for showing where is a pad, track, entity, etc.
* The BOARD is needed because layer names are (somewhat) customizable
*/
wxString LayerMaskDescribe( const BOARD* aBoard, LSET aMask );
/**
* Returns a netname layer corresponding to the given layer.

View File

@ -60,6 +60,16 @@ static inline wxString FROM_UTF8( const char* cstring )
return line;
}
/// Utility to build comma separated lists in messages
inline void AccumulateDescription( wxString &aDesc, const wxString &aItem )
{
if( !aDesc.IsEmpty() )
aDesc << wxT(", ");
aDesc << aItem;
}
/**
* Function GetChars
* returns a wxChar* to the actual wxChar* data within a wxString, and is

View File

@ -1,42 +0,0 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 1992-2014 KiCad Developers, see AUTHORS.txt for contributors.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, you may find one here:
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
* or you may search the http://www.gnu.org website for the version 2 license,
* or you may write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
/**
* @file pcbcommon.h
*/
#ifndef PCBCOMMON_H_
#define PCBCOMMON_H_
class PGM_BASE;
/// Utility for comma separated lists
inline void AccumulateDescription( wxString &aDesc, const wxString &aItem )
{
if( !aDesc.IsEmpty() )
aDesc << wxT(", ");
aDesc << aItem;
}
#endif // PCBCOMMON_H_

View File

@ -45,6 +45,14 @@
#include <convert_basic_shapes_to_polygon.h>
/**
* Helper function
* Return a string (to be shown to the user) describing a layer mask.
* Useful for showing where is a pad.
* The BOARD is needed because layer names are (somewhat) customizable
*/
static wxString LayerMaskDescribe( const BOARD* aBoard, LSET aMask );
int D_PAD::m_PadSketchModePenSize = 0; // Pen size used to draw pads in sketch mode
@ -991,3 +999,40 @@ const BOX2I D_PAD::ViewBBox() const
return BOX2I( VECTOR2I( bbox.GetOrigin() ) - VECTOR2I( xMargin, yMargin ),
VECTOR2I( bbox.GetSize() ) + VECTOR2I( 2 * xMargin, 2 * yMargin ) );
}
wxString LayerMaskDescribe( const BOARD *aBoard, LSET aMask )
{
// Try the single or no- layer case (easy)
LAYER_ID layer = aMask.ExtractLayer();
switch( (int) layer )
{
case UNSELECTED_LAYER:
return _( "No layers" );
case UNDEFINED_LAYER:
break;
default:
return aBoard->GetLayerName( layer );
}
// Try to be smart and useful, starting with outer copper
// (which are more important than internal ones)
wxString layerInfo;
if( aMask[F_Cu] )
AccumulateDescription( layerInfo, aBoard->GetLayerName( F_Cu ) );
if( aMask[B_Cu] )
AccumulateDescription( layerInfo, aBoard->GetLayerName( B_Cu ) );
if( ( aMask & LSET::InternalCuMask() ).any() )
AccumulateDescription( layerInfo, _("Internal" ) );
if( ( aMask & LSET::AllNonCuMask() ).any() )
AccumulateDescription( layerInfo, _("Non-copper" ) );
return layerInfo;
}

View File

@ -34,7 +34,6 @@
#include <class_pcb_screen.h>
#include <class_drawpanel.h>
#include <kicad_string.h>
#include <pcbcommon.h>
#include <colors_selection.h>
#include <richio.h>
#include <macros.h>

View File

@ -36,7 +36,6 @@
#include <confirm.h>
#include <pcbnew.h>
#include <wxBasePcbFrame.h>
#include <pcbcommon.h>
#include <base_units.h>
#include <board_commit.h>

View File

@ -32,12 +32,9 @@
#ifndef _DIALOG_PAD_PROPERTIES_H_
#define _DIALOG_PAD_PROPERTIES_H_
#include <fctsys.h>
#include <common.h>
#include <class_drawpanel.h>
#include <pcbnew.h>
#include <wxBasePcbFrame.h>
#include <pcbcommon.h>
#include <base_units.h>
#include <wx/valnum.h>

View File

@ -40,7 +40,6 @@
#include <class_drawpanel.h>
#include <wxPcbStruct.h>
#include <eda_dde.h>
#include <pcbcommon.h>
#include <colors_selection.h>
#include <wx/stdpaths.h>

View File

@ -32,7 +32,6 @@ using namespace std::placeholders;
#include <macros.h>
#include <pcbnew_id.h>
#include <view/view_controls.h>
#include <pcbcommon.h>
#include <pcb_painter.h>
#include <dialogs/dialog_pns_settings.h>
#include <dialogs/dialog_pns_diff_pair_dimensions.h>

View File

@ -34,7 +34,6 @@ using namespace std::placeholders;
#include <pcbnew_id.h>
#include <view/view.h>
#include <view/view_controls.h>
#include <pcbcommon.h>
#include <pcb_painter.h>
#include <dialogs/dialog_pns_settings.h>
#include <dialogs/dialog_pns_diff_pair_dimensions.h>