From 6d1e9043349aeec23ad2b43456de775ef7dd8a98 Mon Sep 17 00:00:00 2001 From: jean-pierre charras Date: Sun, 5 Jun 2016 13:49:25 +0200 Subject: [PATCH] Code cleanup: Remove outdated decimils to/from iu defines and conversion functions (decimils are no more in use since a long time). Remove convert_from_iu.h file, only used for one define, and containing brokenand duplicate defines. Only convert_to_biu.h is now used. --- common/wxunittext.cpp | 53 ---------------- eeschema/libedit_plot_component.cpp | 4 +- eeschema/plot_schematic_DXF.cpp | 3 +- eeschema/plot_schematic_HPGL.cpp | 3 +- eeschema/plot_schematic_PDF.cpp | 3 +- eeschema/plot_schematic_PS.cpp | 3 +- eeschema/plot_schematic_SVG.cpp | 3 +- gerbview/class_gbr_screen.cpp | 66 ++++++++++---------- gerbview/class_gbr_screen.h | 2 +- include/convert_from_iu.h | 69 --------------------- include/convert_to_biu.h | 43 +++++++------ pcbnew/basepcbframe.cpp | 2 +- pcbnew/class_board_design_settings.cpp | 2 +- pcbnew/class_dimension.cpp | 2 +- pcbnew/class_marker_pcb.cpp | 2 +- pcbnew/class_pad.cpp | 8 +-- pcbnew/classpcb.cpp | 6 +- pcbnew/dialogs/dialog_SVG_print.cpp | 2 +- pcbnew/dialogs/dialog_export_idf.cpp | 2 +- pcbnew/exporters/export_d356.cpp | 2 +- pcbnew/exporters/export_gencad.cpp | 13 ++-- pcbnew/exporters/export_idf.cpp | 1 - pcbnew/exporters/export_vrml.cpp | 2 +- pcbnew/exporters/gen_drill_report_files.cpp | 10 +-- pcbnew/import_dxf/dialog_dxf_import.cpp | 2 +- pcbnew/import_dxf/dxf2brd_items.cpp | 1 - pcbnew/kicad_plugin.cpp | 2 +- pcbnew/legacy_plugin.cpp | 24 +++---- pcbnew/pcb_parser.cpp | 31 +++++---- pcbnew/pcbframe.cpp | 2 +- pcbnew/pcbnew.h | 8 +-- pcbnew/plot_board_layers.cpp | 2 +- scripting/kicad.i | 2 - 33 files changed, 133 insertions(+), 247 deletions(-) delete mode 100644 include/convert_from_iu.h diff --git a/common/wxunittext.cpp b/common/wxunittext.cpp index 16f649ae30..646fb90b65 100644 --- a/common/wxunittext.cpp +++ b/common/wxunittext.cpp @@ -109,59 +109,6 @@ void WX_UNIT_TEXT::SetValue( double aValue ) } -/*boost::optional WX_UNIT_TEXT::GetValue( EDA_UNITS_T aUnit ) const -{ - if( aUnit == m_units ) - return GetValue(); // no conversion needed - - switch( m_units ) - { - case MILLIMETRES: - switch( aUnit ) - { - case INCHES: - iu = Mils2iu( GetValue() * 1000.0 ); - break; - - case UNSCALED_UNITS: - iu = GetValue(); - break; - } - break; - - case INCHES: - switch( aUnit ) - { - case MILLIMETRES: - return Mils2mm( GetValue() * 1000.0 ); - break; - - case UNSCALED_UNITS: - return Mils2iu( GetValue() * 1000.0 ); - break; - } - break; - - case UNSCALED_UNITS: - switch( aUnit ) - { - case MILLIMETRES: - return Iu2Mils( GetValue() ) / 1000.0; - break; - -// case INCHES: -// return -// break; - } - break; - } - - assert( false ); // seems that there are some conversions missing - - return 0.0; -}*/ - - boost::optional WX_UNIT_TEXT::GetValue() const { wxString text = m_inputValue->GetValue(); diff --git a/eeschema/libedit_plot_component.cpp b/eeschema/libedit_plot_component.cpp index ccdca67a08..98fad7bde4 100644 --- a/eeschema/libedit_plot_component.cpp +++ b/eeschema/libedit_plot_component.cpp @@ -156,7 +156,9 @@ void LIB_EDIT_FRAME::SVG_PlotComponent( const wxString& aFullFileName ) wxPoint plot_offset; const double scale = 1.0; - plotter->SetViewport( plot_offset, IU_PER_DECIMILS, scale, false ); + + // Currently, plot units are in decimil + plotter->SetViewport( plot_offset, IU_PER_MILS/10, scale, false ); // Init : plotter->SetCreator( wxT( "Eeschema-SVG" ) ); diff --git a/eeschema/plot_schematic_DXF.cpp b/eeschema/plot_schematic_DXF.cpp index af4b0c2ccd..d79c354308 100644 --- a/eeschema/plot_schematic_DXF.cpp +++ b/eeschema/plot_schematic_DXF.cpp @@ -115,7 +115,8 @@ bool DIALOG_PLOT_SCHEMATIC::PlotOneSheetDXF( const wxString& aFileName, const PAGE_INFO& pageInfo = aScreen->GetPageSettings(); plotter->SetPageSettings( pageInfo ); plotter->SetColorMode( getModeColor() ); - plotter->SetViewport( aPlotOffset, IU_PER_DECIMILS, aScale, false ); + // Currently, plot units are in decimil + plotter->SetViewport( aPlotOffset, IU_PER_MILS/10, aScale, false ); // Init : plotter->SetCreator( wxT( "Eeschema-DXF" ) ); diff --git a/eeschema/plot_schematic_HPGL.cpp b/eeschema/plot_schematic_HPGL.cpp index cd954d1a1a..6248a32181 100644 --- a/eeschema/plot_schematic_HPGL.cpp +++ b/eeschema/plot_schematic_HPGL.cpp @@ -208,7 +208,8 @@ bool DIALOG_PLOT_SCHEMATIC::Plot_1_Page_HPGL( const wxString& aFileName, HPGL_PLOTTER* plotter = new HPGL_PLOTTER(); plotter->SetPageSettings( aPageInfo ); - plotter->SetViewport( aPlot0ffset, IU_PER_DECIMILS, aScale, false ); + // Currently, plot units are in decimil + plotter->SetViewport( aPlot0ffset, IU_PER_MILS/10, aScale, false ); // Init : plotter->SetCreator( wxT( "Eeschema-HPGL" ) ); diff --git a/eeschema/plot_schematic_PDF.cpp b/eeschema/plot_schematic_PDF.cpp index fa68f29b5f..a168821a80 100644 --- a/eeschema/plot_schematic_PDF.cpp +++ b/eeschema/plot_schematic_PDF.cpp @@ -188,6 +188,7 @@ void DIALOG_PLOT_SCHEMATIC::setupPlotPagePDF( PLOTTER * aPlotter, SCH_SCREEN* aS double scaley = (double) plotPage.GetHeightMils() / actualPage.GetHeightMils(); double scale = std::min( scalex, scaley ); aPlotter->SetPageSettings( plotPage ); - aPlotter->SetViewport( wxPoint( 0, 0 ), IU_PER_DECIMILS, scale, false ); + // Currently, plot units are in decimil + aPlotter->SetViewport( wxPoint( 0, 0 ), IU_PER_MILS/10, scale, false ); } diff --git a/eeschema/plot_schematic_PS.cpp b/eeschema/plot_schematic_PS.cpp index fe5d0713fc..86250727f1 100644 --- a/eeschema/plot_schematic_PS.cpp +++ b/eeschema/plot_schematic_PS.cpp @@ -140,7 +140,8 @@ bool DIALOG_PLOT_SCHEMATIC::plotOneSheetPS( const wxString& aFileName, plotter->SetPageSettings( aPageInfo ); plotter->SetDefaultLineWidth( GetDefaultLineThickness() ); plotter->SetColorMode( getModeColor() ); - plotter->SetViewport( aPlot0ffset, IU_PER_DECIMILS, aScale, false ); + // Currently, plot units are in decimil + plotter->SetViewport( aPlot0ffset, IU_PER_MILS/10, aScale, false ); // Init : plotter->SetCreator( wxT( "Eeschema-PS" ) ); diff --git a/eeschema/plot_schematic_SVG.cpp b/eeschema/plot_schematic_SVG.cpp index d704c8e92e..d0835a76e9 100644 --- a/eeschema/plot_schematic_SVG.cpp +++ b/eeschema/plot_schematic_SVG.cpp @@ -114,7 +114,8 @@ bool DIALOG_PLOT_SCHEMATIC::plotOneSheetSVG( EDA_DRAW_FRAME* aFrame, plotter->SetColorMode( aPlotBlackAndWhite ? false : true ); wxPoint plot_offset; double scale = 1.0; - plotter->SetViewport( plot_offset, IU_PER_DECIMILS, scale, false ); + // Currently, plot units are in decimil + plotter->SetViewport( plot_offset, IU_PER_MILS/10, scale, false ); // Init : plotter->SetCreator( wxT( "Eeschema-SVG" ) ); diff --git a/gerbview/class_gbr_screen.cpp b/gerbview/class_gbr_screen.cpp index 82251280e4..47311ebba6 100644 --- a/gerbview/class_gbr_screen.cpp +++ b/gerbview/class_gbr_screen.cpp @@ -33,8 +33,8 @@ #include -#define DMIL_GRID( x ) wxRealPoint( x * IU_PER_DECIMILS,\ - x * IU_PER_DECIMILS ) +#define MIL_GRID( x ) wxRealPoint( x * IU_PER_MILS,\ + x * IU_PER_MILS) #define MM_GRID( x ) wxRealPoint( x * IU_PER_MM,\ x * IU_PER_MM ) @@ -45,46 +45,46 @@ */ static const double gbrZoomList[] = { - ZOOM_FACTOR( 0.5 ), - ZOOM_FACTOR( 0.75 ), + ZOOM_FACTOR( 0.05 ), + ZOOM_FACTOR( 0.075 ), + ZOOM_FACTOR( 0.1 ), + ZOOM_FACTOR( 0.15 ), + ZOOM_FACTOR( 0.2 ), + ZOOM_FACTOR( 0.3 ), + ZOOM_FACTOR( 0.45 ), + ZOOM_FACTOR( 0.7 ), ZOOM_FACTOR( 1.0 ), ZOOM_FACTOR( 1.5 ), - ZOOM_FACTOR( 2.0 ), - ZOOM_FACTOR( 3.0 ), - ZOOM_FACTOR( 4.5 ), - ZOOM_FACTOR( 7.0 ), - ZOOM_FACTOR( 10.0 ), + ZOOM_FACTOR( 2.2 ), + ZOOM_FACTOR( 3.5 ), + ZOOM_FACTOR( 5.0 ), + ZOOM_FACTOR( 8.0 ), + ZOOM_FACTOR( 11.0 ), ZOOM_FACTOR( 15.0 ), - ZOOM_FACTOR( 22.0 ), + ZOOM_FACTOR( 20.0 ), ZOOM_FACTOR( 35.0 ), ZOOM_FACTOR( 50.0 ), - ZOOM_FACTOR( 80.0 ), - ZOOM_FACTOR( 110.0 ), - ZOOM_FACTOR( 150.0 ), - ZOOM_FACTOR( 200.0 ), - ZOOM_FACTOR( 350.0 ), - ZOOM_FACTOR( 500.0 ), - ZOOM_FACTOR( 1000.0 ), - ZOOM_FACTOR( 2000.0 ) + ZOOM_FACTOR( 100.0 ), + ZOOM_FACTOR( 200.0 ) }; // Default grid sizes for PCB editor screens. static GRID_TYPE gbrGridList[] = { - // predefined grid list in 0.0001 inches - { ID_POPUP_GRID_LEVEL_1000, DMIL_GRID( 1000 ) }, - { ID_POPUP_GRID_LEVEL_500, DMIL_GRID( 500 ) }, - { ID_POPUP_GRID_LEVEL_250, DMIL_GRID( 250 ) }, - { ID_POPUP_GRID_LEVEL_200, DMIL_GRID( 200 ) }, - { ID_POPUP_GRID_LEVEL_100, DMIL_GRID( 100 ) }, - { ID_POPUP_GRID_LEVEL_50, DMIL_GRID( 50 ) }, - { ID_POPUP_GRID_LEVEL_25, DMIL_GRID( 25 ) }, - { ID_POPUP_GRID_LEVEL_20, DMIL_GRID( 20 ) }, - { ID_POPUP_GRID_LEVEL_10, DMIL_GRID( 10 ) }, - { ID_POPUP_GRID_LEVEL_5, DMIL_GRID( 5 ) }, - { ID_POPUP_GRID_LEVEL_2, DMIL_GRID( 2 ) }, - { ID_POPUP_GRID_LEVEL_1, DMIL_GRID( 1 ) }, + // predefined grid list in mils + { ID_POPUP_GRID_LEVEL_1000, MIL_GRID( 100 ) }, + { ID_POPUP_GRID_LEVEL_500, MIL_GRID( 50 ) }, + { ID_POPUP_GRID_LEVEL_250, MIL_GRID( 25 ) }, + { ID_POPUP_GRID_LEVEL_200, MIL_GRID( 20 ) }, + { ID_POPUP_GRID_LEVEL_100, MIL_GRID( 10 ) }, + { ID_POPUP_GRID_LEVEL_50, MIL_GRID( 5 ) }, + { ID_POPUP_GRID_LEVEL_25, MIL_GRID( 2.5 ) }, + { ID_POPUP_GRID_LEVEL_20, MIL_GRID( 2 ) }, + { ID_POPUP_GRID_LEVEL_10, MIL_GRID( 1 ) }, + { ID_POPUP_GRID_LEVEL_5, MIL_GRID( 0.5 ) }, + { ID_POPUP_GRID_LEVEL_2, MIL_GRID( 0.2 ) }, + { ID_POPUP_GRID_LEVEL_1, MIL_GRID( 0.1 ) }, // predefined grid list in mm { ID_POPUP_GRID_LEVEL_5MM, MM_GRID( 5.0 ) }, @@ -109,8 +109,8 @@ GBR_SCREEN::GBR_SCREEN( const wxSize& aPageSizeIU ) : for( unsigned i = 0; i < DIM( gbrGridList ); ++i ) AddGrid( gbrGridList[i] ); - // Set the working grid size to a reasonable value (in 1/10000 inch) - SetGrid( DMIL_GRID( 500 ) ); + // Set the working grid size to a reasonable value + SetGrid( MIL_GRID( 50 ) ); SetZoom( ZOOM_FACTOR( 350 ) ); // a default value for zoom m_Active_Layer = 0; // default active layer = first graphic layer diff --git a/gerbview/class_gbr_screen.h b/gerbview/class_gbr_screen.h index d137675bd6..920b9931dc 100644 --- a/gerbview/class_gbr_screen.h +++ b/gerbview/class_gbr_screen.h @@ -34,7 +34,7 @@ #include #include -#define ZOOM_FACTOR( x ) ( x * IU_PER_DECIMILS ) +#define ZOOM_FACTOR( x ) ( x * IU_PER_MILS ) /* Handle info to display a board */ class GBR_SCREEN : public BASE_SCREEN diff --git a/include/convert_from_iu.h b/include/convert_from_iu.h deleted file mode 100644 index 1164d2173a..0000000000 --- a/include/convert_from_iu.h +++ /dev/null @@ -1,69 +0,0 @@ -/* - * This program source code file is part of KiCad, a free EDA CAD application. - * - * Copyright (C) 2012 CERN - * - * 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 convert_from_iu.h - * @brief Definitions and functions to convert from internal units to user units - * depending upon the application and/or build options. - */ - - -#ifndef _CONVERT_FROM_IU_ -#define _CONVERT_FROM_IU_ - - -/// Convert from internal units to user units. -#if defined(PCBNEW) || defined(CVPCB) || defined(GERBVIEW) - #if defined(GERBVIEW) - #define MM_PER_IU 1.0 / 1e5 // Gerbview uses 10 micrometer. - #else - #define MM_PER_IU 1.0 / 1e6 // Pcbnew in nanometers. - #endif - #define MILS_PER_IU ( MM_PER_IU * 0.0254 ) - #define DECIMILS_PER_IU (MM_PER_IU * 0.00254 ) - -/// Convert PCBNEW internal units (iu) to mils. -inline int Iu2Mils( int iu ) -{ - double x = iu * MILS_PER_IU; - return int( x < 0 ? x - 0.5 : x + 0.5 ); -} - -/// Convert PCBNEW internal units (iu) to deci-mils. -inline int Iu2DMils( int iu ) -{ - double x = iu * DECIMILS_PER_IU; - return int( x < 0 ? x - 0.5 : x + 0.5 ); -} - -#else // Eeschema and anything else. -#define MILS_PER_IU 1.0 -#define MM_PER_IU (MILS_PER_IU / 0.0254) - -inline int Iu2Mils( int iu ) -{ - return iu; -} -#endif - -#endif // #define _CONVERT_FROM_IU_ diff --git a/include/convert_to_biu.h b/include/convert_to_biu.h index 646a319822..5d6d0f9c30 100644 --- a/include/convert_to_biu.h +++ b/include/convert_to_biu.h @@ -1,8 +1,8 @@ /* * This program source code file is part of KiCad, a free EDA CAD application. * - * Copyright (C) 2012-2014 Jean-Pierre Charras, jp.charras at wanadoo.fr - * Copyright (C) 1992-2014 KiCad Developers, see CHANGELOG.TXT for contributors. + * Copyright (C) 2012-2016 Jean-Pierre Charras, jp.charras at wanadoo.fr + * Copyright (C) 1992-2016 KiCad Developers, see CHANGELOG.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 @@ -46,7 +46,6 @@ #define IU_PER_MM 1e6 // Pcbnew IU is 1 nanometer. #endif #define IU_PER_MILS (IU_PER_MM * 0.0254) - #define IU_PER_DECIMILS (IU_PER_MM * 0.00254) /// Convert mils to PCBNEW internal units (iu). inline int Mils2iu( int mils ) @@ -55,17 +54,9 @@ inline int Mils2iu( int mils ) return int( x < 0 ? x - 0.5 : x + 0.5 ); } -/// Convert deci-mils to PCBNEW internal units (iu). -inline int DMils2iu( int dmils ) -{ - double x = dmils * IU_PER_DECIMILS; - return int( x < 0 ? x - 0.5 : x + 0.5 ); -} - #elif defined (PL_EDITOR) #define IU_PER_MM 1e3 // internal units in micron (should be enough) #define IU_PER_MILS (IU_PER_MM * 0.0254) -#define IU_PER_DECIMILS (IU_PER_MM * 0.00254) /// Convert mils to page layout editor internal units (iu). inline int Mils2iu( int mils ) { @@ -73,15 +64,7 @@ inline int Mils2iu( int mils ) return int( x < 0 ? x - 0.5 : x + 0.5 ); } -/// Convert deci-mils to page layout editor internal units (iu). -inline int DMils2iu( int dmils ) -{ - double x = dmils * IU_PER_DECIMILS; - return int( x < 0 ? x - 0.5 : x + 0.5 ); -} - -#else // Eeschema and anything else. -#define IU_PER_DECIMILS 0.1 +#elif defined (EESCHEMA) // Eeschema #define IU_PER_MILS 1.0 #define IU_PER_MM (IU_PER_MILS / 0.0254) @@ -89,13 +72,33 @@ inline int Mils2iu( int mils ) { return mils; } +#else +// Here, we do not know the value of internal units: do not define +// conversion functions (They do not have meaning +#define UNKNOWN_IU #endif +#ifndef UNKNOWN_IU +// Other definitions used in a few files +#define MM_PER_IU (1/IU_PER_MM) + /// Convert mm to internal units (iu). inline int Millimeter2iu( double mm ) { return (int) ( mm < 0 ? mm * IU_PER_MM - 0.5 : mm * IU_PER_MM + 0.5); } +/// Convert mm to internal units (iu). +inline double Iu2Millimeter( int iu ) +{ + return iu / IU_PER_MM; +} + +/// Convert mm to internal units (iu). +inline double Iu2Mils( int iu ) +{ + return iu / IU_PER_MILS; +} +#endif #endif // CONVERT_TO_BIU_H_ diff --git a/pcbnew/basepcbframe.cpp b/pcbnew/basepcbframe.cpp index ff212cc32a..e95d2c68de 100644 --- a/pcbnew/basepcbframe.cpp +++ b/pcbnew/basepcbframe.cpp @@ -107,7 +107,7 @@ PCB_BASE_FRAME::PCB_BASE_FRAME( KIWAY* aKiway, wxWindow* aParent, FRAME_T aFrame m_auxiliaryToolBar = NULL; - m_zoomLevelCoeff = 110.0 * IU_PER_DECIMILS; // Adjusted to roughly displays zoom level = 1 + m_zoomLevelCoeff = 11.0 * IU_PER_MILS; // Adjusted to roughly displays zoom level = 1 // when the screen shows a 1:1 image // obviously depends on the monitor, // but this is an acceptable value diff --git a/pcbnew/class_board_design_settings.cpp b/pcbnew/class_board_design_settings.cpp index 49b3de0df0..d53a2081c2 100644 --- a/pcbnew/class_board_design_settings.cpp +++ b/pcbnew/class_board_design_settings.cpp @@ -34,7 +34,7 @@ #include #include -#include +#include BOARD_DESIGN_SETTINGS::BOARD_DESIGN_SETTINGS() : diff --git a/pcbnew/class_dimension.cpp b/pcbnew/class_dimension.cpp index 262ae7a8f0..fab0cd2142 100644 --- a/pcbnew/class_dimension.cpp +++ b/pcbnew/class_dimension.cpp @@ -231,7 +231,7 @@ void DIMENSION::UpdateHeight() void DIMENSION::AdjustDimensionDetails( bool aDoNotChangeText ) { - const int arrowz = DMils2iu( 500 ); // size of arrows + const int arrowz = Mils2iu( 50 ); // size of arrows int ii; int measure, deltax, deltay; // value of the measure on X and Y axes int arrow_up_X = 0, arrow_up_Y = 0; // coordinates of arrow line / diff --git a/pcbnew/class_marker_pcb.cpp b/pcbnew/class_marker_pcb.cpp index dd7d4e17a8..f625d8177f 100644 --- a/pcbnew/class_marker_pcb.cpp +++ b/pcbnew/class_marker_pcb.cpp @@ -41,7 +41,7 @@ /// Adjust the actual size of markers, when using default shape -#define SCALING_FACTOR DMils2iu( 30 ) +#define SCALING_FACTOR Mils2iu( 3 ) MARKER_PCB::MARKER_PCB( BOARD_ITEM* aParent ) : diff --git a/pcbnew/class_pad.cpp b/pcbnew/class_pad.cpp index b638e078f0..f2cd0cf422 100644 --- a/pcbnew/class_pad.cpp +++ b/pcbnew/class_pad.cpp @@ -41,7 +41,7 @@ #include #include #include -#include +#include #include #include @@ -53,9 +53,9 @@ D_PAD::D_PAD( MODULE* parent ) : BOARD_CONNECTED_ITEM( parent, PCB_PAD_T ) { m_NumPadName = 0; - m_Size.x = m_Size.y = DMils2iu( 600 ); // Default pad size 60 mils. - m_Drill.x = m_Drill.y = DMils2iu( 300 ); // Default drill size 30 mils. - m_Orient = 0; // Pad rotation in 1/10 degrees. + m_Size.x = m_Size.y = Mils2iu( 60 ); // Default pad size 60 mils. + m_Drill.x = m_Drill.y = Mils2iu( 30 ); // Default drill size 30 mils. + m_Orient = 0; // Pad rotation in 1/10 degrees. m_LengthPadToDie = 0; if( m_Parent && m_Parent->Type() == PCB_MODULE_T ) diff --git a/pcbnew/classpcb.cpp b/pcbnew/classpcb.cpp index 367f8af956..c568e5d0d7 100644 --- a/pcbnew/classpcb.cpp +++ b/pcbnew/classpcb.cpp @@ -45,9 +45,9 @@ #include -#define ZOOM_FACTOR( x ) ( x * IU_PER_DECIMILS ) -#define DMIL_GRID( x ) wxRealPoint( x * IU_PER_DECIMILS,\ - x * IU_PER_DECIMILS ) +#define ZOOM_FACTOR( x ) ( x * IU_PER_MILS / 10 ) +#define DMIL_GRID( x ) wxRealPoint( x * IU_PER_MILS / 10,\ + x * IU_PER_MILS / 10 ) #define MM_GRID( x ) wxRealPoint( x * IU_PER_MM,\ x * IU_PER_MM ) diff --git a/pcbnew/dialogs/dialog_SVG_print.cpp b/pcbnew/dialogs/dialog_SVG_print.cpp index e78fb133ee..0c95e3beb7 100644 --- a/pcbnew/dialogs/dialog_SVG_print.cpp +++ b/pcbnew/dialogs/dialog_SVG_print.cpp @@ -34,7 +34,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/pcbnew/dialogs/dialog_export_idf.cpp b/pcbnew/dialogs/dialog_export_idf.cpp index 5878c3b93c..1beb178bd8 100644 --- a/pcbnew/dialogs/dialog_export_idf.cpp +++ b/pcbnew/dialogs/dialog_export_idf.cpp @@ -29,7 +29,7 @@ #include #include #include -#include +#include // IDF export header generated by wxFormBuilder #include diff --git a/pcbnew/exporters/export_d356.cpp b/pcbnew/exporters/export_d356.cpp index ed9ed98d30..ab3e581327 100644 --- a/pcbnew/exporters/export_d356.cpp +++ b/pcbnew/exporters/export_d356.cpp @@ -104,7 +104,7 @@ static int compute_pad_access_code( BOARD *aPcb, LSET aLayerMask ) /* Convert and clamp a size from IU to decimils */ static int iu_to_d356(int iu, int clamp) { - int val = KiROUND( iu / IU_PER_DECIMILS ); + int val = KiROUND( iu / ( IU_PER_MILS / 10 ) ); if( val > clamp ) return clamp; if( val < -clamp ) return -clamp; return val; diff --git a/pcbnew/exporters/export_gencad.cpp b/pcbnew/exporters/export_gencad.cpp index 15b32e78be..0ffa023877 100644 --- a/pcbnew/exporters/export_gencad.cpp +++ b/pcbnew/exporters/export_gencad.cpp @@ -220,9 +220,8 @@ static std::string fmt_mask( LSET aSet ) // These are the export origin (the auxiliary axis) static int GencadOffsetX, GencadOffsetY; -/* GerbTool chokes on units different than INCH so this is the conversion - * factor */ -const static double SCALE_FACTOR = 10000.0 * IU_PER_DECIMILS; +// GerbTool chokes on units different than INCH so this is the conversion factor +const static double SCALE_FACTOR = 1000.0 * IU_PER_MILS; /* Two helper functions to calculate coordinates of modules in gencad values @@ -782,7 +781,7 @@ static void CreateSignalsSection( FILE* aFile, BOARD* aPcb ) if( net->GetNetname() == wxEmptyString ) // dummy netlist (no connection) { - wxString msg; msg << wxT( "NoConnection" ) << NbNoConn++; + msg.Printf( "NoConnection%d", NbNoConn++ ); } if( net->GetNet() <= 0 ) // dummy netlist (no connection) @@ -1243,8 +1242,12 @@ static void FootprintWriteShape( FILE* aFile, MODULE* module ) break; } + case S_POLYGON: + // Not exported (TODO) + break; + default: - DisplayError( NULL, wxT( "Type Edge Module invalid." ) ); + DisplayError( NULL, wxString::Format( "Type Edge Module %d invalid.", PtStruct->Type() ) ); break; } } diff --git a/pcbnew/exporters/export_idf.cpp b/pcbnew/exporters/export_idf.cpp index bcbff69321..cd3f421b59 100644 --- a/pcbnew/exporters/export_idf.cpp +++ b/pcbnew/exporters/export_idf.cpp @@ -36,7 +36,6 @@ #include #include <3d_struct.h> #include -#include #ifndef PCBNEW #define PCBNEW // needed to define the right value of Millimeter2iu(x) diff --git a/pcbnew/exporters/export_vrml.cpp b/pcbnew/exporters/export_vrml.cpp index 20ae2dc715..98804a8300 100644 --- a/pcbnew/exporters/export_vrml.cpp +++ b/pcbnew/exporters/export_vrml.cpp @@ -45,7 +45,7 @@ #include #include #include -#include +#include #include "../3d-viewer/modelparsers.h" diff --git a/pcbnew/exporters/gen_drill_report_files.cpp b/pcbnew/exporters/gen_drill_report_files.cpp index d2c9820c4b..85562a22da 100644 --- a/pcbnew/exporters/gen_drill_report_files.cpp +++ b/pcbnew/exporters/gen_drill_report_files.cpp @@ -79,7 +79,7 @@ bool EXCELLON_WRITER::GenDrillMapFile( const wxString& aFullFileName, case PLOT_FORMAT_GERBER: offset = GetOffset(); plotter = new GERBER_PLOTTER(); - plotter->SetViewport( offset, IU_PER_DECIMILS, scale, false ); + plotter->SetViewport( offset, IU_PER_MILS/10, scale, false ); plotter->SetGerberCoordinatesFormat( 5 ); // format x.5 unit = mm break; @@ -90,7 +90,7 @@ bool EXCELLON_WRITER::GenDrillMapFile( const wxString& aFullFileName, hpgl_plotter->SetPenNumber( plot_opts.GetHPGLPenNum() ); hpgl_plotter->SetPenSpeed( plot_opts.GetHPGLPenSpeed() ); plotter->SetPageSettings( page_info ); - plotter->SetViewport( offset, IU_PER_DECIMILS, scale, false ); + plotter->SetViewport( offset, IU_PER_MILS/10, scale, false ); } break; @@ -133,7 +133,7 @@ bool EXCELLON_WRITER::GenDrillMapFile( const wxString& aFullFileName, plotter = new PS_PLOTTER; plotter->SetPageSettings( pageA4 ); - plotter->SetViewport( offset, IU_PER_DECIMILS, scale, false ); + plotter->SetViewport( offset, IU_PER_MILS/10, scale, false ); } break; @@ -142,7 +142,7 @@ bool EXCELLON_WRITER::GenDrillMapFile( const wxString& aFullFileName, DXF_PLOTTER* dxf_plotter = new DXF_PLOTTER; plotter = dxf_plotter; plotter->SetPageSettings( page_info ); - plotter->SetViewport( offset, IU_PER_DECIMILS, scale, false ); + plotter->SetViewport( offset, IU_PER_MILS/10, scale, false ); } break; @@ -151,7 +151,7 @@ bool EXCELLON_WRITER::GenDrillMapFile( const wxString& aFullFileName, SVG_PLOTTER* svg_plotter = new SVG_PLOTTER; plotter = svg_plotter; plotter->SetPageSettings( page_info ); - plotter->SetViewport( offset, IU_PER_DECIMILS, scale, false ); + plotter->SetViewport( offset, IU_PER_MILS/10, scale, false ); } break; } diff --git a/pcbnew/import_dxf/dialog_dxf_import.cpp b/pcbnew/import_dxf/dialog_dxf_import.cpp index 7b1e569927..76d84c4d83 100644 --- a/pcbnew/import_dxf/dialog_dxf_import.cpp +++ b/pcbnew/import_dxf/dialog_dxf_import.cpp @@ -29,7 +29,7 @@ #include #include -#include +#include #include #include diff --git a/pcbnew/import_dxf/dxf2brd_items.cpp b/pcbnew/import_dxf/dxf2brd_items.cpp index 8efc051449..34ca51b88a 100644 --- a/pcbnew/import_dxf/dxf2brd_items.cpp +++ b/pcbnew/import_dxf/dxf2brd_items.cpp @@ -45,7 +45,6 @@ #include #include #include -#include #include // minimum bulge value before resorting to a line segment; diff --git a/pcbnew/kicad_plugin.cpp b/pcbnew/kicad_plugin.cpp index ed61809392..b3c15409ab 100644 --- a/pcbnew/kicad_plugin.cpp +++ b/pcbnew/kicad_plugin.cpp @@ -88,7 +88,7 @@ class FP_CACHE_ITEM { wxFileName m_file_name; ///< The the full file name and path of the footprint to cache. wxDateTime m_mod_time; ///< The last file modified time stamp. - std::auto_ptr m_module; + std::unique_ptr m_module; public: FP_CACHE_ITEM( MODULE* aModule, const wxFileName& aFileName ); diff --git a/pcbnew/legacy_plugin.cpp b/pcbnew/legacy_plugin.cpp index 54ccdc880b..b95081ff7c 100644 --- a/pcbnew/legacy_plugin.cpp +++ b/pcbnew/legacy_plugin.cpp @@ -238,7 +238,7 @@ static inline char* ReadLine( LINE_READER* rdr, const char* caller ) -using namespace std; // auto_ptr +using namespace std; // unique_ptr static EDA_TEXT_HJUSTIFY_T horizJustify( const char* horizontal ) @@ -401,7 +401,7 @@ BOARD* LEGACY_PLUGIN::Load( const wxString& aFileName, BOARD* aAppendToMe, m_board->SetFileName( aFileName ); // delete on exception, iff I own m_board, according to aAppendToMe - auto_ptr deleter( aAppendToMe ? NULL : m_board ); + unique_ptr deleter( aAppendToMe ? NULL : m_board ); FILE_LINE_READER reader( aFileName ); @@ -433,7 +433,7 @@ void LEGACY_PLUGIN::loadAllSections( bool doAppend ) if( TESTLINE( "$MODULE" ) ) { - auto_ptr module( new MODULE( m_board ) ); + unique_ptr module( new MODULE( m_board ) ); FPID fpid; std::string fpName = StrPurge( line + SZ( "$MODULE" ) ); @@ -1386,7 +1386,7 @@ void LEGACY_PLUGIN::loadMODULE( MODULE* aModule ) void LEGACY_PLUGIN::loadPAD( MODULE* aModule ) { - auto_ptr pad( new D_PAD( aModule ) ); + unique_ptr pad( new D_PAD( aModule ) ); char* line; char* saveptr; @@ -1644,7 +1644,7 @@ void LEGACY_PLUGIN::loadMODULE_EDGE( MODULE* aModule ) THROW_IO_ERROR( m_error ); } - auto_ptr dwg( new EDGE_MODULE( aModule, shape ) ); // a drawing + unique_ptr dwg( new EDGE_MODULE( aModule, shape ) ); // a drawing const char* data; @@ -1942,7 +1942,7 @@ void LEGACY_PLUGIN::loadPCB_LINE() $EndDRAWSEGMENT */ - auto_ptr dseg( new DRAWSEGMENT( m_board ) ); + unique_ptr dseg( new DRAWSEGMENT( m_board ) ); char* line; char* saveptr; @@ -2406,7 +2406,7 @@ void LEGACY_PLUGIN::loadNETCLASS() // create an empty NETCLASS without a name, but do not add it to the BOARD // yet since that would bypass duplicate netclass name checking within the BOARD. - // store it temporarily in an auto_ptr until successfully inserted into the BOARD + // store it temporarily in an unique_ptr until successfully inserted into the BOARD // just before returning. NETCLASSPTR nc = boost::make_shared( wxEmptyString ); @@ -2475,7 +2475,7 @@ void LEGACY_PLUGIN::loadNETCLASS() // Must have been a name conflict, this is a bad board file. // User may have done a hand edit to the file. - // auto_ptr will delete nc on this code path + // unique_ptr will delete nc on this code path m_error.Printf( _( "duplicate NETCLASS name '%s'" ), nc->GetName().GetData() ); THROW_IO_ERROR( m_error ); @@ -2491,7 +2491,7 @@ void LEGACY_PLUGIN::loadNETCLASS() void LEGACY_PLUGIN::loadZONE_CONTAINER() { - auto_ptr zc( new ZONE_CONTAINER( m_board ) ); + unique_ptr zc( new ZONE_CONTAINER( m_board ) ); CPolyLine::HATCH_STYLE outline_hatch = CPolyLine::NO_HATCH; bool sawCorner = false; @@ -2760,7 +2760,7 @@ void LEGACY_PLUGIN::loadZONE_CONTAINER() void LEGACY_PLUGIN::loadDIMENSION() { - auto_ptr dim( new DIMENSION( m_board ) ); + unique_ptr dim( new DIMENSION( m_board ) ); char* line; char* saveptr; @@ -3079,7 +3079,7 @@ void LEGACY_PLUGIN::init( const PROPERTIES* aProperties ) // mm to nanometers. The deci-mil legacy files have no such "Units" marker // so we must assume the file is in deci-mils until told otherwise. - diskToBiu = IU_PER_DECIMILS; // BIUs are nanometers + diskToBiu = IU_PER_MILS / 10; // BIUs are nanometers } @@ -3310,7 +3310,7 @@ void LP_CACHE::LoadModules( LINE_READER* aReader ) // test first for the $MODULE, even before reading because of INDEX bug. if( TESTLINE( "$MODULE" ) ) { - auto_ptr module( new MODULE( m_owner->m_board ) ); + unique_ptr module( new MODULE( m_owner->m_board ) ); std::string footprintName = StrPurge( line + SZ( "$MODULE" ) ); diff --git a/pcbnew/pcb_parser.cpp b/pcbnew/pcb_parser.cpp index 3c6ca00d6e..63e955bc05 100644 --- a/pcbnew/pcb_parser.cpp +++ b/pcbnew/pcb_parser.cpp @@ -31,7 +31,6 @@ #include #include #include -#include #include #include <3d_struct.h> #include @@ -346,7 +345,7 @@ S3D_MASTER* PCB_PARSER::parse3DModel() throw( PARSE_ERROR, IO_ERROR ) T token; - std::auto_ptr< S3D_MASTER > n3D( new S3D_MASTER( NULL ) ); + std::unique_ptr< S3D_MASTER > n3D( new S3D_MASTER( NULL ) ); NeedSYMBOLorNUMBER(); n3D->SetShape3DName( FromUTF8() ); @@ -419,7 +418,7 @@ BOARD_ITEM* PCB_PARSER::Parse() throw( IO_ERROR, PARSE_ERROR ) // MODULEs can be prefixed with an initial block of single line comments and these // are kept for Format() so they round trip in s-expression form. BOARDs might // eventually do the same, but currently do not. - std::auto_ptr initial_comments( ReadCommentLines() ); + std::unique_ptr initial_comments( ReadCommentLines() ); token = CurTok(); @@ -1323,7 +1322,7 @@ void PCB_PARSER::parseNETCLASS() throw( IO_ERROR, PARSE_ERROR ) // Must have been a name conflict, this is a bad board file. // User may have done a hand edit to the file. - // auto_ptr will delete nc on this code path + // unique_ptr will delete nc on this code path wxString error; error.Printf( _( "duplicate NETCLASS name '%s' in file <%s> at line %d, offset %d" ), @@ -1341,7 +1340,7 @@ DRAWSEGMENT* PCB_PARSER::parseDRAWSEGMENT() throw( IO_ERROR, PARSE_ERROR ) T token; wxPoint pt; - std::auto_ptr< DRAWSEGMENT > segment( new DRAWSEGMENT( NULL ) ); + std::unique_ptr< DRAWSEGMENT > segment( new DRAWSEGMENT( NULL ) ); switch( CurTok() ) { @@ -1502,7 +1501,7 @@ TEXTE_PCB* PCB_PARSER::parseTEXTE_PCB() throw( IO_ERROR, PARSE_ERROR ) T token; - std::auto_ptr text( new TEXTE_PCB( m_board ) ); + std::unique_ptr text( new TEXTE_PCB( m_board ) ); NeedSYMBOLorNUMBER(); text->SetText( FromUTF8() ); @@ -1570,7 +1569,7 @@ DIMENSION* PCB_PARSER::parseDIMENSION() throw( IO_ERROR, PARSE_ERROR ) T token; - std::auto_ptr dimension( new DIMENSION( NULL ) ); + std::unique_ptr dimension( new DIMENSION( NULL ) ); dimension->SetValue( parseBoardUnits( "dimension value" ) ); NeedLEFT(); @@ -1743,7 +1742,7 @@ MODULE* PCB_PARSER::parseMODULE_unchecked( wxArrayString* aInitialComments ) T token; FPID fpid; - std::auto_ptr module( new MODULE( m_board ) ); + std::unique_ptr module( new MODULE( m_board ) ); module->SetInitialComments( aInitialComments ); @@ -1956,7 +1955,7 @@ MODULE* PCB_PARSER::parseMODULE_unchecked( wxArrayString* aInitialComments ) case T_pad: { D_PAD* pad = parseD_PAD( module.get() ); - wxPoint pt = pad->GetPos0(); + pt = pad->GetPos0(); RotatePoint( &pt, module->GetOrientation() ); pad->SetPosition( pt + module->GetPosition() ); @@ -1993,7 +1992,7 @@ TEXTE_MODULE* PCB_PARSER::parseTEXTE_MODULE() throw( IO_ERROR, PARSE_ERROR ) T token = NextTok(); - std::auto_ptr text( new TEXTE_MODULE( NULL ) ); + std::unique_ptr text( new TEXTE_MODULE( NULL ) ); switch( token ) { @@ -2078,7 +2077,7 @@ EDGE_MODULE* PCB_PARSER::parseEDGE_MODULE() throw( IO_ERROR, PARSE_ERROR ) wxPoint pt; T token; - std::auto_ptr< EDGE_MODULE > segment( new EDGE_MODULE( NULL ) ); + std::unique_ptr< EDGE_MODULE > segment( new EDGE_MODULE( NULL ) ); switch( CurTok() ) { @@ -2244,7 +2243,7 @@ D_PAD* PCB_PARSER::parseD_PAD( MODULE* aParent ) throw( IO_ERROR, PARSE_ERROR ) wxSize sz; wxPoint pt; - std::auto_ptr< D_PAD > pad( new D_PAD( aParent ) ); + std::unique_ptr< D_PAD > pad( new D_PAD( aParent ) ); NeedSYMBOLorNUMBER(); pad->SetPadName( FromUTF8() ); @@ -2498,7 +2497,7 @@ TRACK* PCB_PARSER::parseTRACK() throw( IO_ERROR, PARSE_ERROR ) wxPoint pt; T token; - std::auto_ptr< TRACK > track( new TRACK( m_board ) ); + std::unique_ptr< TRACK > track( new TRACK( m_board ) ); for( token = NextTok(); token != T_RIGHT; token = NextTok() ) { @@ -2564,7 +2563,7 @@ VIA* PCB_PARSER::parseVIA() throw( IO_ERROR, PARSE_ERROR ) wxPoint pt; T token; - std::auto_ptr< VIA > via( new VIA( m_board ) ); + std::unique_ptr< VIA > via( new VIA( m_board ) ); for( token = NextTok(); token != T_RIGHT; token = NextTok() ) { @@ -2656,7 +2655,7 @@ ZONE_CONTAINER* PCB_PARSER::parseZONE_CONTAINER() throw( IO_ERROR, PARSE_ERROR ) // bigger scope since each filled_polygon is concatenated in here SHAPE_POLY_SET pts; - std::auto_ptr< ZONE_CONTAINER > zone( new ZONE_CONTAINER( m_board ) ); + std::unique_ptr< ZONE_CONTAINER > zone( new ZONE_CONTAINER( m_board ) ); zone->SetPriority( 0 ); @@ -3014,7 +3013,7 @@ PCB_TARGET* PCB_PARSER::parsePCB_TARGET() throw( IO_ERROR, PARSE_ERROR ) wxPoint pt; T token; - std::auto_ptr< PCB_TARGET > target( new PCB_TARGET( NULL ) ); + std::unique_ptr< PCB_TARGET > target( new PCB_TARGET( NULL ) ); for( token = NextTok(); token != T_RIGHT; token = NextTok() ) { diff --git a/pcbnew/pcbframe.cpp b/pcbnew/pcbframe.cpp index 3a8c9c16e0..2ec99bab53 100644 --- a/pcbnew/pcbframe.cpp +++ b/pcbnew/pcbframe.cpp @@ -53,7 +53,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/pcbnew/pcbnew.h b/pcbnew/pcbnew.h index 3f31119fd8..8f0f37006e 100644 --- a/pcbnew/pcbnew.h +++ b/pcbnew/pcbnew.h @@ -33,7 +33,7 @@ #include // wxWidgets include. #include // IS_DRAGGED and IN_EDIT definitions. #include -#include // to define DMils2iu() conversion function +#include // to define Mils2iu() conversion function #include // Arcs are approximated by segments: define the number of segments per 360 deg (KiCad uses 0.1 @@ -59,9 +59,9 @@ enum ENDPOINT_T { #define DIM_ANCRE_MODULE 3 // Anchor size (footprint center) -#define TEXTS_MIN_SIZE DMils2iu( 50 ) ///< Minimum text size in Pcbnew units value (50 * 0.0001 mils) -#define TEXTS_MAX_SIZE DMils2iu( 10000 ) ///< Maximum text size in Pcbnew units value (1 inch) ) -#define TEXTS_MAX_WIDTH DMils2iu( 5000 ) ///< Maximum text width in Pcbnew units value (0.5 inches) +#define TEXTS_MIN_SIZE Mils2iu( 5 ) ///< Minimum text size in Pcbnew units value (5 mils) +#define TEXTS_MAX_SIZE Mils2iu( 1000 ) ///< Maximum text size in Pcbnew units value (1 inch) ) +#define TEXTS_MAX_WIDTH Mils2iu( 500 ) ///< Maximum text width in Pcbnew units value (0.5 inches) #define MIN_DRAW_WIDTH 1 ///< Minimum trace drawing width in pixels. diff --git a/pcbnew/plot_board_layers.cpp b/pcbnew/plot_board_layers.cpp index 083856580f..68a027e735 100644 --- a/pcbnew/plot_board_layers.cpp +++ b/pcbnew/plot_board_layers.cpp @@ -868,7 +868,7 @@ static void initializePlotter( PLOTTER *aPlotter, BOARD * aBoard, most of that taken from the options */ aPlotter->SetPageSettings( *sheet_info ); - aPlotter->SetViewport( offset, IU_PER_DECIMILS, compound_scale, + aPlotter->SetViewport( offset, IU_PER_MILS/10, compound_scale, aPlotOpts->GetMirror() ); // has meaning only for gerber plotter. Must be called only after SetViewport aPlotter->SetGerberCoordinatesFormat( aPlotOpts->GetGerberPrecision() ); diff --git a/scripting/kicad.i b/scripting/kicad.i index 073c11231e..6316a6dcae 100644 --- a/scripting/kicad.i +++ b/scripting/kicad.i @@ -72,7 +72,6 @@ #include #include #include - #include #include %} @@ -105,7 +104,6 @@ %include %include %include -%include %include %include