From b8b08dafd669a0dc6e0892691c1cf6be4c54a4cc Mon Sep 17 00:00:00 2001 From: jean-pierre charras Date: Sat, 31 Dec 2016 12:56:00 +0100 Subject: [PATCH] Code cleaning: remove pcbcommon.* which contains nothing really useful. The very few lines of code are moved to a better place. --- common/CMakeLists.txt | 1 - common/pcbcommon.cpp | 73 ----------------------- cvpcb/class_DisplayFootprintsFrame.cpp | 4 +- cvpcb/cvpcb.cpp | 1 - include/layers_id_colors_and_visibility.h | 6 -- include/macros.h | 10 ++++ include/pcbcommon.h | 42 ------------- pcbnew/class_pad.cpp | 45 ++++++++++++++ pcbnew/class_zone.cpp | 1 - pcbnew/dialogs/dialog_pad_properties.cpp | 1 - pcbnew/dialogs/dialog_pad_properties.h | 3 - pcbnew/pcbnew.cpp | 1 - pcbnew/router/pns_tool_base.cpp | 1 - pcbnew/router/router_tool.cpp | 1 - 14 files changed, 56 insertions(+), 134 deletions(-) delete mode 100644 common/pcbcommon.cpp delete mode 100644 include/pcbcommon.h diff --git a/common/CMakeLists.txt b/common/CMakeLists.txt index 034fa552dd..210f7545a9 100644 --- a/common/CMakeLists.txt +++ b/common/CMakeLists.txt @@ -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 diff --git a/common/pcbcommon.cpp b/common/pcbcommon.cpp deleted file mode 100644 index 02c9d9ea97..0000000000 --- a/common/pcbcommon.cpp +++ /dev/null @@ -1,73 +0,0 @@ -/* - * This program source code file is part of KiCad, a free EDA CAD application. - * - * Copyright (C) 2008 Wayne Stambaugh - * 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 -#include -#include - -#include -#include - - -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; -} - diff --git a/cvpcb/class_DisplayFootprintsFrame.cpp b/cvpcb/class_DisplayFootprintsFrame.cpp index 50706ecb58..3888361e4a 100644 --- a/cvpcb/class_DisplayFootprintsFrame.cpp +++ b/cvpcb/class_DisplayFootprintsFrame.cpp @@ -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 * Copyright (C) 2007-2016 KiCad Developers, see AUTHORS.txt for contributors. * @@ -28,7 +28,6 @@ */ #include -#include #include #include #include @@ -39,7 +38,6 @@ #include #include #include -#include #include #include diff --git a/cvpcb/cvpcb.cpp b/cvpcb/cvpcb.cpp index b40dc0137d..c7a98aa034 100644 --- a/cvpcb/cvpcb.cpp +++ b/cvpcb/cvpcb.cpp @@ -34,7 +34,6 @@ #include #include #include -#include #include #include diff --git a/include/layers_id_colors_and_visibility.h b/include/layers_id_colors_and_visibility.h index 42b83c5946..3ac8c90557 100644 --- a/include/layers_id_colors_and_visibility.h +++ b/include/layers_id_colors_and_visibility.h @@ -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. diff --git a/include/macros.h b/include/macros.h index bf81070340..e216dcd327 100644 --- a/include/macros.h +++ b/include/macros.h @@ -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 diff --git a/include/pcbcommon.h b/include/pcbcommon.h deleted file mode 100644 index 7dbb5b6abb..0000000000 --- a/include/pcbcommon.h +++ /dev/null @@ -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_ diff --git a/pcbnew/class_pad.cpp b/pcbnew/class_pad.cpp index 081e020a46..cab53dbda6 100644 --- a/pcbnew/class_pad.cpp +++ b/pcbnew/class_pad.cpp @@ -45,6 +45,14 @@ #include +/** + * 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; +} diff --git a/pcbnew/class_zone.cpp b/pcbnew/class_zone.cpp index 912f47ace1..0ac7966a05 100644 --- a/pcbnew/class_zone.cpp +++ b/pcbnew/class_zone.cpp @@ -34,7 +34,6 @@ #include #include #include -#include #include #include #include diff --git a/pcbnew/dialogs/dialog_pad_properties.cpp b/pcbnew/dialogs/dialog_pad_properties.cpp index a73eaeb783..cfa50d3e6e 100644 --- a/pcbnew/dialogs/dialog_pad_properties.cpp +++ b/pcbnew/dialogs/dialog_pad_properties.cpp @@ -36,7 +36,6 @@ #include #include #include -#include #include #include diff --git a/pcbnew/dialogs/dialog_pad_properties.h b/pcbnew/dialogs/dialog_pad_properties.h index 09541c8204..74ffac520d 100644 --- a/pcbnew/dialogs/dialog_pad_properties.h +++ b/pcbnew/dialogs/dialog_pad_properties.h @@ -32,12 +32,9 @@ #ifndef _DIALOG_PAD_PROPERTIES_H_ #define _DIALOG_PAD_PROPERTIES_H_ -#include -#include #include #include #include -#include #include #include diff --git a/pcbnew/pcbnew.cpp b/pcbnew/pcbnew.cpp index 5f6189e67b..b760c5b202 100644 --- a/pcbnew/pcbnew.cpp +++ b/pcbnew/pcbnew.cpp @@ -40,7 +40,6 @@ #include #include #include -#include #include #include diff --git a/pcbnew/router/pns_tool_base.cpp b/pcbnew/router/pns_tool_base.cpp index b4aafec5ae..0f90500d3a 100644 --- a/pcbnew/router/pns_tool_base.cpp +++ b/pcbnew/router/pns_tool_base.cpp @@ -32,7 +32,6 @@ using namespace std::placeholders; #include #include #include -#include #include #include #include diff --git a/pcbnew/router/router_tool.cpp b/pcbnew/router/router_tool.cpp index f3c37b5966..144e2d1617 100644 --- a/pcbnew/router/router_tool.cpp +++ b/pcbnew/router/router_tool.cpp @@ -34,7 +34,6 @@ using namespace std::placeholders; #include #include #include -#include #include #include #include