diff --git a/common/eda_text.cpp b/common/eda_text.cpp index 93b2e82f06..cc234ad4e5 100644 --- a/common/eda_text.cpp +++ b/common/eda_text.cpp @@ -35,24 +35,7 @@ #include // EDA_DRAW_PANEL #include - -// Conversion to application internal units defined at build time. -#if defined( PCBNEW ) - #include - #define FMT_IU BOARD_ITEM::FormatInternalUnits - #define FMT_ANGLE BOARD_ITEM::FormatAngle -#elif defined( EESCHEMA ) - #include - #define FMT_IU SCH_ITEM::FormatInternalUnits - #define FMT_ANGLE SCH_ITEM::FormatAngle -#elif defined( GERBVIEW ) -#elif defined( PL_EDITOR ) - #include - #define FMT_IU Double2Str -#else -#error "Cannot resolve units formatting due to no definition of EESCHEMA or PCBNEW." -#endif - +#include #include EDA_TEXT::EDA_TEXT( const wxString& text ) : diff --git a/include/unit_format.h b/include/unit_format.h new file mode 100644 index 0000000000..4cf5c71728 --- /dev/null +++ b/include/unit_format.h @@ -0,0 +1,44 @@ +/* + * This program source code file is part of KiCad, a free EDA CAD application. + * + * Copyright (C) 2017 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 + */ + +#ifndef UNIT_FORMAT_H +#define UNIT_FORMAT_H + +// Conversion to application internal units defined at build time. +#if defined( PCBNEW ) + #include + #define FMT_IU BOARD_ITEM::FormatInternalUnits + #define FMT_ANGLE BOARD_ITEM::FormatAngle +#elif defined( EESCHEMA ) + #include + #define FMT_IU SCH_ITEM::FormatInternalUnits + #define FMT_ANGLE SCH_ITEM::FormatAngle +#elif defined( GERBVIEW ) +#elif defined( PL_EDITOR ) + #include + #define FMT_IU Double2Str +#else +#error "Cannot resolve units formatting due to no definition of EESCHEMA or PCBNEW." +#endif + +#endif /* UNIT_FORMAT_H */ diff --git a/pcbnew/dialogs/dialog_pad_basicshapes_properties.cpp b/pcbnew/dialogs/dialog_pad_basicshapes_properties.cpp index 2f80070bed..c2088cbb18 100644 --- a/pcbnew/dialogs/dialog_pad_basicshapes_properties.cpp +++ b/pcbnew/dialogs/dialog_pad_basicshapes_properties.cpp @@ -37,6 +37,7 @@ #include #include #include +#include #include #include diff --git a/pcbnew/dialogs/dialog_pad_properties.cpp b/pcbnew/dialogs/dialog_pad_properties.cpp index 65b32b7d69..292c700e12 100644 --- a/pcbnew/dialogs/dialog_pad_properties.cpp +++ b/pcbnew/dialogs/dialog_pad_properties.cpp @@ -38,6 +38,7 @@ #include #include #include +#include #include #include diff --git a/pcbnew/kicad_plugin.cpp b/pcbnew/kicad_plugin.cpp index 06145c660f..21d4b7ce3a 100644 --- a/pcbnew/kicad_plugin.cpp +++ b/pcbnew/kicad_plugin.cpp @@ -53,7 +53,8 @@ using namespace PCB_KEYS_T; -#define FMTIU BOARD_ITEM::FormatInternalUnits +#define FMT_IU BOARD_ITEM::FormatInternalUnits +#define FMT_ANGLE BOARD_ITEM::FormatAngle /** * @ingroup trace_env_vars @@ -538,105 +539,105 @@ void PCB_IO::formatSetup( BOARD* aBoard, int aNestLevel ) const // Save current default track width, for compatibility with older Pcbnew version; m_out->Print( aNestLevel+1, "(last_trace_width %s)\n", - FMTIU( dsnSettings.GetCurrentTrackWidth() ).c_str() ); + FMT_IU( dsnSettings.GetCurrentTrackWidth() ).c_str() ); // Save custom tracks width list (the first is not saved here: this is the netclass value for( unsigned ii = 1; ii < dsnSettings.m_TrackWidthList.size(); ii++ ) m_out->Print( aNestLevel+1, "(user_trace_width %s)\n", - FMTIU( dsnSettings.m_TrackWidthList[ii] ).c_str() ); + FMT_IU( dsnSettings.m_TrackWidthList[ii] ).c_str() ); m_out->Print( aNestLevel+1, "(trace_clearance %s)\n", - FMTIU( dsnSettings.GetDefault()->GetClearance() ).c_str() ); + FMT_IU( dsnSettings.GetDefault()->GetClearance() ).c_str() ); // ZONE_SETTINGS m_out->Print( aNestLevel+1, "(zone_clearance %s)\n", - FMTIU( aBoard->GetZoneSettings().m_ZoneClearance ).c_str() ); + FMT_IU( aBoard->GetZoneSettings().m_ZoneClearance ).c_str() ); m_out->Print( aNestLevel+1, "(zone_45_only %s)\n", aBoard->GetZoneSettings().m_Zone_45_Only ? "yes" : "no" ); m_out->Print( aNestLevel+1, "(trace_min %s)\n", - FMTIU( dsnSettings.m_TrackMinWidth ).c_str() ); + FMT_IU( dsnSettings.m_TrackMinWidth ).c_str() ); m_out->Print( aNestLevel+1, "(segment_width %s)\n", - FMTIU( dsnSettings.m_DrawSegmentWidth ).c_str() ); + FMT_IU( dsnSettings.m_DrawSegmentWidth ).c_str() ); m_out->Print( aNestLevel+1, "(edge_width %s)\n", - FMTIU( dsnSettings.m_EdgeSegmentWidth ).c_str() ); + FMT_IU( dsnSettings.m_EdgeSegmentWidth ).c_str() ); // Save current default via size, for compatibility with older Pcbnew version; m_out->Print( aNestLevel+1, "(via_size %s)\n", - FMTIU( dsnSettings.GetDefault()->GetViaDiameter() ).c_str() ); + FMT_IU( dsnSettings.GetDefault()->GetViaDiameter() ).c_str() ); m_out->Print( aNestLevel+1, "(via_drill %s)\n", - FMTIU( dsnSettings.GetDefault()->GetViaDrill() ).c_str() ); + FMT_IU( dsnSettings.GetDefault()->GetViaDrill() ).c_str() ); m_out->Print( aNestLevel+1, "(via_min_size %s)\n", - FMTIU( dsnSettings.m_ViasMinSize ).c_str() ); + FMT_IU( dsnSettings.m_ViasMinSize ).c_str() ); m_out->Print( aNestLevel+1, "(via_min_drill %s)\n", - FMTIU( dsnSettings.m_ViasMinDrill ).c_str() ); + FMT_IU( dsnSettings.m_ViasMinDrill ).c_str() ); // Save custom vias diameters list (the first is not saved here: this is // the netclass value for( unsigned ii = 1; ii < dsnSettings.m_ViasDimensionsList.size(); ii++ ) m_out->Print( aNestLevel+1, "(user_via %s %s)\n", - FMTIU( dsnSettings.m_ViasDimensionsList[ii].m_Diameter ).c_str(), - FMTIU( dsnSettings.m_ViasDimensionsList[ii].m_Drill ).c_str() ); + FMT_IU( dsnSettings.m_ViasDimensionsList[ii].m_Diameter ).c_str(), + FMT_IU( dsnSettings.m_ViasDimensionsList[ii].m_Drill ).c_str() ); // for old versions compatibility: if( dsnSettings.m_BlindBuriedViaAllowed ) m_out->Print( aNestLevel+1, "(blind_buried_vias_allowed yes)\n" ); m_out->Print( aNestLevel+1, "(uvia_size %s)\n", - FMTIU( dsnSettings.GetDefault()->GetuViaDiameter() ).c_str() ); + FMT_IU( dsnSettings.GetDefault()->GetuViaDiameter() ).c_str() ); m_out->Print( aNestLevel+1, "(uvia_drill %s)\n", - FMTIU( dsnSettings.GetDefault()->GetuViaDrill() ).c_str() ); + FMT_IU( dsnSettings.GetDefault()->GetuViaDrill() ).c_str() ); m_out->Print( aNestLevel+1, "(uvias_allowed %s)\n", ( dsnSettings.m_MicroViasAllowed ) ? "yes" : "no" ); m_out->Print( aNestLevel+1, "(uvia_min_size %s)\n", - FMTIU( dsnSettings.m_MicroViasMinSize ).c_str() ); + FMT_IU( dsnSettings.m_MicroViasMinSize ).c_str() ); m_out->Print( aNestLevel+1, "(uvia_min_drill %s)\n", - FMTIU( dsnSettings.m_MicroViasMinDrill ).c_str() ); + FMT_IU( dsnSettings.m_MicroViasMinDrill ).c_str() ); m_out->Print( aNestLevel+1, "(pcb_text_width %s)\n", - FMTIU( dsnSettings.m_PcbTextWidth ).c_str() ); + FMT_IU( dsnSettings.m_PcbTextWidth ).c_str() ); m_out->Print( aNestLevel+1, "(pcb_text_size %s %s)\n", - FMTIU( dsnSettings.m_PcbTextSize.x ).c_str(), - FMTIU( dsnSettings.m_PcbTextSize.y ).c_str() ); + FMT_IU( dsnSettings.m_PcbTextSize.x ).c_str(), + FMT_IU( dsnSettings.m_PcbTextSize.y ).c_str() ); m_out->Print( aNestLevel+1, "(mod_edge_width %s)\n", - FMTIU( dsnSettings.m_ModuleSegmentWidth ).c_str() ); + FMT_IU( dsnSettings.m_ModuleSegmentWidth ).c_str() ); m_out->Print( aNestLevel+1, "(mod_text_size %s %s)\n", - FMTIU( dsnSettings.m_ModuleTextSize.x ).c_str(), - FMTIU( dsnSettings.m_ModuleTextSize.y ).c_str() ); + FMT_IU( dsnSettings.m_ModuleTextSize.x ).c_str(), + FMT_IU( dsnSettings.m_ModuleTextSize.y ).c_str() ); m_out->Print( aNestLevel+1, "(mod_text_width %s)\n", - FMTIU( dsnSettings.m_ModuleTextWidth ).c_str() ); + FMT_IU( dsnSettings.m_ModuleTextWidth ).c_str() ); m_out->Print( aNestLevel+1, "(pad_size %s %s)\n", - FMTIU( dsnSettings.m_Pad_Master.GetSize().x ).c_str(), - FMTIU( dsnSettings.m_Pad_Master.GetSize().y ).c_str() ); + FMT_IU( dsnSettings.m_Pad_Master.GetSize().x ).c_str(), + FMT_IU( dsnSettings.m_Pad_Master.GetSize().y ).c_str() ); m_out->Print( aNestLevel+1, "(pad_drill %s)\n", - FMTIU( dsnSettings.m_Pad_Master.GetDrillSize().x ).c_str() ); + FMT_IU( dsnSettings.m_Pad_Master.GetDrillSize().x ).c_str() ); m_out->Print( aNestLevel+1, "(pad_to_mask_clearance %s)\n", - FMTIU( dsnSettings.m_SolderMaskMargin ).c_str() ); + FMT_IU( dsnSettings.m_SolderMaskMargin ).c_str() ); if( dsnSettings.m_SolderMaskMinWidth ) m_out->Print( aNestLevel+1, "(solder_mask_min_width %s)\n", - FMTIU( dsnSettings.m_SolderMaskMinWidth ).c_str() ); + FMT_IU( dsnSettings.m_SolderMaskMinWidth ).c_str() ); if( dsnSettings.m_SolderPasteMargin != 0 ) m_out->Print( aNestLevel+1, "(pad_to_paste_clearance %s)\n", - FMTIU( dsnSettings.m_SolderPasteMargin ).c_str() ); + FMT_IU( dsnSettings.m_SolderPasteMargin ).c_str() ); if( dsnSettings.m_SolderPasteMarginRatio != 0 ) m_out->Print( aNestLevel+1, "(pad_to_paste_clearance_ratio %s)\n", Double2Str( dsnSettings.m_SolderPasteMarginRatio ).c_str() ); m_out->Print( aNestLevel+1, "(aux_axis_origin %s %s)\n", - FMTIU( aBoard->GetAuxOrigin().x ).c_str(), - FMTIU( aBoard->GetAuxOrigin().y ).c_str() ); + FMT_IU( aBoard->GetAuxOrigin().x ).c_str(), + FMT_IU( aBoard->GetAuxOrigin().y ).c_str() ); if( aBoard->GetGridOrigin().x || aBoard->GetGridOrigin().y ) m_out->Print( aNestLevel+1, "(grid_origin %s %s)\n", - FMTIU( aBoard->GetGridOrigin().x ).c_str(), - FMTIU( aBoard->GetGridOrigin().y ).c_str() ); + FMT_IU( aBoard->GetGridOrigin().x ).c_str(), + FMT_IU( aBoard->GetGridOrigin().y ).c_str() ); m_out->Print( aNestLevel+1, "(visible_elements %X)\n", dsnSettings.GetVisibleElements() ); @@ -655,7 +656,7 @@ void PCB_IO::formatGeneral( BOARD* aBoard, int aNestLevel ) const m_out->Print( aNestLevel, "(general\n" ); // Write Bounding box info m_out->Print( aNestLevel+1, "(thickness %s)\n", - FMTIU( dsnSettings.GetBoardThickness() ).c_str() ); + FMT_IU( dsnSettings.GetBoardThickness() ).c_str() ); m_out->Print( aNestLevel+1, "(drawings %d)\n", aBoard->Drawings().Size() ); m_out->Print( aNestLevel+1, "(tracks %d)\n", aBoard->GetNumSegmTrack() );