From 40aee428b56b47d251e29b18da3c941ef505a0c7 Mon Sep 17 00:00:00 2001 From: Wayne Stambaugh Date: Fri, 13 Apr 2012 14:51:24 -0400 Subject: [PATCH] More internal unit improvements. * Move all convert from internal to user units functions into separate file. * Remove internal units parameter from all moved conversion functions. * Revise all source code that calls the moved conversion functions. * Compile these conversion routines separately for the appropriate pcb or schematic internal units. * Move internal units specific status bar update code into the appropriate application for updating the status bar. * Move millimeter user units rounding function to common.cpp. --- common/CMakeLists.txt | 1 + common/base_units.cpp | 161 ++++++++++++++++++ common/common.cpp | 127 +++----------- common/drawframe.cpp | 107 +----------- common/wxwineda.cpp | 36 +++- common/zoom.cpp | 35 +++- eeschema/CMakeLists.txt | 1 + eeschema/dialogs/dialog_SVG_print.cpp | 8 +- .../dialog_edit_component_in_schematic.cpp | 5 +- eeschema/dialogs/dialog_edit_label.cpp | 4 +- .../dialog_edit_libentry_fields_in_lib.cpp | 5 +- eeschema/dialogs/dialog_edit_one_field.cpp | 4 +- eeschema/dialogs/dialog_lib_edit_text.cpp | 7 +- .../dialogs/dialog_plot_schematic_HPGL.cpp | 11 +- eeschema/dialogs/dialog_plot_schematic_PS.cpp | 4 +- .../dialogs/dialog_print_using_printer.cpp | 1 + eeschema/find.cpp | 7 +- eeschema/lib_arc.cpp | 9 +- eeschema/lib_bezier.cpp | 3 +- eeschema/lib_circle.cpp | 11 +- eeschema/lib_field.cpp | 5 +- eeschema/lib_pin.cpp | 3 +- eeschema/lib_polyline.cpp | 9 +- eeschema/lib_rectangle.cpp | 11 +- eeschema/lib_text.cpp | 3 +- eeschema/pinedit.cpp | 9 +- eeschema/sch_base_frame.cpp | 67 ++++++++ eeschema/sch_line.cpp | 9 +- eeschema/sheet.cpp | 9 +- eeschema/sheetlab.cpp | 5 +- eeschema/symbdraw.cpp | 3 +- include/base_units.h | 83 +++++++++ include/common.h | 61 ++----- include/sch_base_frame.h | 2 + pcbnew/basepcbframe.cpp | 84 +++++++-- pcbnew/dialogs/dialog_SVG_print.cpp | 7 +- pcbnew/dialogs/dialog_copper_zones.cpp | 21 +-- pcbnew/dialogs/dialog_design_rules.cpp | 51 ++---- .../dialog_edit_module_for_BoardEditor.cpp | 20 +-- .../dialog_edit_module_for_Modedit.cpp | 14 +- pcbnew/dialogs/dialog_edit_module_text.cpp | 16 +- .../dialog_global_edit_tracks_and_vias.cpp | 22 +-- .../dialog_graphic_item_properties.cpp | 22 +-- ...og_graphic_item_properties_for_Modedit.cpp | 19 +-- .../dialogs/dialog_graphic_items_options.cpp | 34 ++-- pcbnew/dialogs/dialog_mask_clearance.cpp | 10 +- pcbnew/dialogs/dialog_pad_properties.cpp | 38 ++--- pcbnew/dialogs/dialog_pcb_text_properties.cpp | 16 +- pcbnew/dialogs/dialog_print_using_printer.cpp | 7 +- pcbnew/dimension.cpp | 16 +- pcbnew/drc.cpp | 12 +- pcbnew/edgemod.cpp | 4 +- pcbnew/muonde.cpp | 8 +- pcbnew/onrightclick.cpp | 8 +- pcbnew/pcbplot.cpp | 29 ++-- pcbnew/set_grid.cpp | 5 +- pcbnew/zones_non_copper_type_functions.cpp | 5 +- 57 files changed, 715 insertions(+), 579 deletions(-) create mode 100644 common/base_units.cpp create mode 100644 include/base_units.h diff --git a/common/CMakeLists.txt b/common/CMakeLists.txt index cd04595f00..7320e92788 100644 --- a/common/CMakeLists.txt +++ b/common/CMakeLists.txt @@ -83,6 +83,7 @@ add_library(common STATIC ${COMMON_SRCS}) set(PCB_COMMON_SRCS base_screen.cpp + base_units.cpp eda_text.cpp class_page_info.cpp pcbcommon.cpp diff --git a/common/base_units.cpp b/common/base_units.cpp new file mode 100644 index 0000000000..2c1a3fb794 --- /dev/null +++ b/common/base_units.cpp @@ -0,0 +1,161 @@ +/* + * This program source code file is part of KiCad, a free EDA CAD application. + * + * Copyright (C) 2012 CERN + * Copyright (C) 1992-2011 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 + */ + +/** + * @author Wayne Stambaugh + * @file base_units.cpp + * @brief Code to handle objects that require both schematic and board internal units. + * @note This file is an ugly hack to solve the problem of formatting the base units + * for either schematics or boards in objects that are include in both domains. + * At some point in the future. This code should be rolled back into the + * appropriate object and build with the correct internal unit formatting + * depending on the application. + */ + +#include +#include +#include +#include + + +#if defined( PCBNEW ) +#if defined( USE_PCBNEW_NANOMETRES ) +#define IU_TO_MM( x ) ( x * 1e-6 ) +#define IU_TO_IN( x ) ( ( x * 1e-6 ) / 25.4 ) +#else +#define IU_TO_MM( x ) ( ( x * 0.0001 ) * 25.4 ) +#define IU_TO_IN( x ) ( x * 0.0001 ) +#endif +#elif defined( EESCHEMA ) +#define IU_TO_MM( x ) ( ( x * 0.001 ) * 25.4 ) +#define IU_TO_IN( x ) ( x * 0.001 ) +#else +#error "Cannot resolve internal units due to no definition of EESCHEMA or PCBNEW." +#endif + + +double To_User_Unit( EDA_UNITS_T aUnit, double aValue ) +{ + switch( aUnit ) + { + case MILLIMETRES: + return IU_TO_MM( aValue ); + + case INCHES: + return IU_TO_IN( aValue ); + + default: + return aValue; + } +} + + +wxString CoordinateToString( int aValue, bool aConvertToMils ) +{ + wxString text; + const wxChar* format; + double value = To_User_Unit( g_UserUnit, aValue ); + + if( g_UserUnit == INCHES ) + { + if( aConvertToMils ) + { +#if defined( EESCHEMA ) + format = wxT( "%.0f" ); +#else + format = wxT( "%.1f" ); +#endif + if( aConvertToMils ) + value *= 1000; + } + else + { +#if defined( EESCHEMA ) + format = wxT( "%.3f" ); +#else + format = wxT( "%.4f" ); +#endif + } + } + else + { +#if defined( EESCHEMA ) + format = wxT( "%.2f" ); +#else + format = wxT( "%.3f" ); +#endif + } + + text.Printf( format, value ); + + if( g_UserUnit == INCHES ) + text += ( aConvertToMils ) ? _( " mils" ) : _( " in" ); + else + text += _( " mm" ); + + return text; +} + + +wxString ReturnStringFromValue( EDA_UNITS_T aUnit, int aValue, bool aAddUnitSymbol ) +{ + wxString StringValue; + double value_to_print; + + value_to_print = To_User_Unit( aUnit, aValue ); + +#if defined( PCBNEW ) + StringValue.Printf( wxT( "%.4f" ), value_to_print ); +#else + StringValue.Printf( wxT( "%.3f" ), value_to_print ); +#endif + + if( aAddUnitSymbol ) + { + switch( aUnit ) + { + case INCHES: + StringValue += _( " \"" ); + break; + + case MILLIMETRES: + StringValue += _( " mm" ); + break; + + case UNSCALED_UNITS: + break; + } + } + + return StringValue; +} + + +void PutValueInLocalUnits( wxTextCtrl& aTextCtr, int aValue ) +{ + wxString msg = ReturnStringFromValue( g_UserUnit, aValue ); + + aTextCtr.SetValue( msg ); +} diff --git a/common/common.cpp b/common/common.cpp index db77f54ab3..d9292d774c 100644 --- a/common/common.cpp +++ b/common/common.cpp @@ -36,6 +36,8 @@ #include #include #include +#include + #include /** @@ -251,14 +253,6 @@ void AddUnitSymbol( wxStaticText& Stext, EDA_UNITS_T aUnit ) } -void PutValueInLocalUnits( wxTextCtrl& TextCtr, int Value, int Internal_Unit ) -{ - wxString msg = ReturnStringFromValue( g_UserUnit, Value, Internal_Unit ); - - TextCtr.SetValue( msg ); -} - - int ReturnValueFromTextCtrl( const wxTextCtrl& TextCtr, int Internal_Unit ) { int value; @@ -270,37 +264,6 @@ int ReturnValueFromTextCtrl( const wxTextCtrl& TextCtr, int Internal_Unit ) } -wxString ReturnStringFromValue( EDA_UNITS_T aUnit, int aValue, int aInternal_Unit, - bool aAdd_unit_symbol ) -{ - wxString StringValue; - double value_to_print; - - value_to_print = To_User_Unit( aUnit, aValue, aInternal_Unit ); - - // Yet another 'if Pcbnew' :( - StringValue.Printf( ( aInternal_Unit > 1000 ) ? wxT( "%.4f" ) : wxT( "%.3f" ), - value_to_print ); - - if( aAdd_unit_symbol ) - switch( aUnit ) - { - case INCHES: - StringValue += _( " \"" ); - break; - - case MILLIMETRES: - StringValue += _( " mm" ); - break; - - case UNSCALED_UNITS: - break; - } - - return StringValue; -} - - int ReturnValueFromString( EDA_UNITS_T aUnit, const wxString& TextValue, int Internal_Unit ) { int Value; @@ -386,30 +349,6 @@ wxArrayString* wxStringSplit( wxString aString, wxChar aSplitter ) } -/** - * Function To_User_Unit - * Convert in inch or mm the variable "val" (double)given in internal units - * @return the converted value, in double - * @param aUnit : user measure unit - * @param val : double : the given value - * @param internal_unit_value = internal units per inch - */ -double To_User_Unit( EDA_UNITS_T aUnit, double val, int internal_unit_value ) -{ - switch( aUnit ) - { - case MILLIMETRES: - return val * 25.4 / internal_unit_value; - - case INCHES: - return val / internal_unit_value; - - default: - return val; - } -} - - /* * Return in internal units the value "val" given in inch or mm */ @@ -511,45 +450,6 @@ const wxString& valeur_param( int valeur, wxString& buf_texte ) } -wxString CoordinateToString( int aValue, int aInternalUnits, bool aConvertToMils ) -{ - wxCHECK_MSG( (aInternalUnits == EESCHEMA_INTERNAL_UNIT) - || (aInternalUnits == PCB_INTERNAL_UNIT), - wxString( _( "*** Bad Internal Units ***" ) ), - wxT( "Invalid interanl units value." ) ); - - wxString text; - const wxChar* format; - double value = To_User_Unit( g_UserUnit, aValue, aInternalUnits ); - - if( g_UserUnit == INCHES ) - { - if( aConvertToMils ) - { - format = ( aInternalUnits == EESCHEMA_INTERNAL_UNIT ) ? wxT( "%.0f" ) : wxT( "%.1f" ); - value *= 1000; - } - else - { - format = ( aInternalUnits == EESCHEMA_INTERNAL_UNIT ) ? wxT( "%.3f" ) : wxT( "%.4f" ); - } - } - else - { - format = ( aInternalUnits == EESCHEMA_INTERNAL_UNIT ) ? wxT( "%.2f" ) : wxT( "%.3f" ); - } - - text.Printf( format, value ); - - if( g_UserUnit == INCHES ) - text += ( aConvertToMils ) ? _( " mils" ) : _( " in" ); - else - text += _( " mm" ); - - return text; -} - - wxString& operator <<( wxString& aString, const wxPoint& aPos ) { wxString temp; @@ -560,3 +460,26 @@ wxString& operator <<( wxString& aString, const wxPoint& aPos ) return aString; } + + +double RoundTo0( double x, double precision ) +{ + assert( precision != 0 ); + + long long ix = wxRound( x * precision ); + + if ( x < 0.0 ) + NEGATE( ix ); + + int remainder = ix % 10; // remainder is in precision mm + + if ( remainder <= 2 ) + ix -= remainder; // truncate to the near number + else if (remainder >= 8 ) + ix += 10 - remainder; // round to near number + + if ( x < 0 ) + NEGATE( ix ); + + return (double) ix / precision; +} diff --git a/common/drawframe.cpp b/common/drawframe.cpp index 7f5b4510b5..0f9efa3095 100644 --- a/common/drawframe.cpp +++ b/common/drawframe.cpp @@ -40,6 +40,7 @@ #include #include #include +#include #include @@ -714,41 +715,9 @@ void EDA_DRAW_FRAME::SetLanguage( wxCommandEvent& event ) } -/** - * Round to the nearest precision. - * - * Try to approximate a coordinate using a given precision to prevent - * rounding errors when converting from inches to mm. - * - * ie round the unit value to 0 if unit is 1 or 2, or 8 or 9 - */ -double RoundTo0( double x, double precision ) -{ - assert( precision != 0 ); - - long long ix = wxRound( x * precision ); - - if ( x < 0.0 ) - NEGATE( ix ); - - int remainder = ix % 10; // remainder is in precision mm - - if ( remainder <= 2 ) - ix -= remainder; // truncate to the near number - else if (remainder >= 8 ) - ix += 10 - remainder; // round to near number - - if ( x < 0 ) - NEGATE( ix ); - - return (double) ix / precision; -} - - void EDA_DRAW_FRAME::UpdateStatusBar() { wxString Line; - int dx, dy; BASE_SCREEN* screen = GetScreen(); if( !screen ) @@ -759,76 +728,8 @@ void EDA_DRAW_FRAME::UpdateStatusBar() SetStatusText( Line, 1 ); - // Display absolute coordinates: - double dXpos = To_User_Unit( g_UserUnit, screen->GetCrossHairPosition().x, m_internalUnits ); - double dYpos = To_User_Unit( g_UserUnit, screen->GetCrossHairPosition().y, m_internalUnits ); - - /* - * Converting from inches to mm can give some coordinates due to - * float point precision rounding errors, like 1.999 or 2.001 so - * round to the nearest drawing precision required by the application. - */ - if ( g_UserUnit == MILLIMETRES ) - { - dXpos = RoundTo0( dXpos, (double)( m_internalUnits / 10 ) ); - dYpos = RoundTo0( dYpos, (double)( m_internalUnits / 10 ) ); - } - - // The following sadly is an if Eeschema/if Pcbnew - wxString absformatter; - wxString locformatter; - switch( g_UserUnit ) - { - case INCHES: - if( m_internalUnits == EESCHEMA_INTERNAL_UNIT ) - { - absformatter = wxT( "X %.3f Y %.3f" ); - locformatter = wxT( "dx %.3f dy %.3f d %.3f" ); - } - else - { - absformatter = wxT( "X %.4f Y %.4f" ); - locformatter = wxT( "dx %.4f dy %.4f d %.4f" ); - } - break; - - case MILLIMETRES: - if( m_internalUnits == EESCHEMA_INTERNAL_UNIT ) - { - absformatter = wxT( "X %.2f Y %.2f" ); - locformatter = wxT( "dx %.2f dy %.2f d %.2f" ); - } - else - { - absformatter = wxT( "X %.3f Y %.3f" ); - locformatter = wxT( "dx %.3f dy %.3f d %.3f" ); - } - break; - - case UNSCALED_UNITS: - absformatter = wxT( "X %f Y %f" ); - locformatter = wxT( "dx %f dy %f d %f" ); - break; - } - - Line.Printf( absformatter, dXpos, dYpos ); - SetStatusText( Line, 2 ); - - // Display relative coordinates: - dx = screen->GetCrossHairPosition().x - screen->m_O_Curseur.x; - dy = screen->GetCrossHairPosition().y - screen->m_O_Curseur.y; - dXpos = To_User_Unit( g_UserUnit, dx, m_internalUnits ); - dYpos = To_User_Unit( g_UserUnit, dy, m_internalUnits ); - - if( g_UserUnit == MILLIMETRES ) - { - dXpos = RoundTo0( dXpos, (double) ( m_internalUnits / 10 ) ); - dYpos = RoundTo0( dYpos, (double) ( m_internalUnits / 10 ) ); - } - - // We already decided the formatter above - Line.Printf( locformatter, dXpos, dYpos, sqrt( dXpos * dXpos + dYpos * dYpos ) ); - SetStatusText( Line, 3 ); + // Absolute and relative cursor positions are handled by overloading this function and + // handling the internal to user units conversion at the appropriate level. // refresh units display DisplayUnitsMsg(); @@ -893,7 +794,7 @@ void EDA_DRAW_FRAME::ClearMsgPanel( void ) wxString EDA_DRAW_FRAME::CoordinateToString( int aValue, bool aConvertToMils ) { - return ::CoordinateToString( aValue, m_internalUnits, aConvertToMils ); + return ::CoordinateToString( aValue, aConvertToMils ); } diff --git a/common/wxwineda.cpp b/common/wxwineda.cpp index 0f09081609..b0105eaaa8 100644 --- a/common/wxwineda.cpp +++ b/common/wxwineda.cpp @@ -1,3 +1,27 @@ +/* + * This program source code file is part of KiCad, a free EDA CAD application. + * + * Copyright (C) 2004 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com + * Copyright (C) 1992-2011 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 wxwineda.cpp */ @@ -5,6 +29,7 @@ #include #include #include +#include /*******************************************************/ @@ -72,7 +97,7 @@ wxString EDA_GRAPHIC_TEXT_CTRL::FormatSize( int internalUnit, EDA_UNITS_T aUnit, textSize = 3000; value.Printf( ( internalUnit > 1000 ) ? wxT( "%.4f" ) : wxT( "%.3f" ), - To_User_Unit( aUnit, textSize, internalUnit ) ); + To_User_Unit( aUnit, textSize ) ); return value; } @@ -220,11 +245,11 @@ void EDA_POSITION_CTRL::SetValue( int x_value, int y_value ) m_Pos_To_Edit.x = x_value; m_Pos_To_Edit.y = y_value; - msg = ReturnStringFromValue( m_UserUnit, m_Pos_To_Edit.x, m_Internal_Unit ); + msg = ReturnStringFromValue( m_UserUnit, m_Pos_To_Edit.x ); m_FramePosX->Clear(); m_FramePosX->SetValue( msg ); - msg = ReturnStringFromValue( m_UserUnit, m_Pos_To_Edit.y, m_Internal_Unit ); + msg = ReturnStringFromValue( m_UserUnit, m_Pos_To_Edit.y ); m_FramePosY->Clear(); m_FramePosY->SetValue( msg ); } @@ -274,8 +299,7 @@ EDA_VALUE_CTRL::EDA_VALUE_CTRL( wxWindow* parent, const wxString& title, BoxSizer->Add( m_Text, 0, wxGROW | wxLEFT | wxRIGHT | wxTOP, 5 ); - wxString stringvalue = ReturnStringFromValue( m_UserUnit, m_Value, - m_Internal_Unit ); + wxString stringvalue = ReturnStringFromValue( m_UserUnit, m_Value ); m_ValueCtrl = new wxTextCtrl( parent, -1, stringvalue ); BoxSizer->Add( m_ValueCtrl, @@ -308,7 +332,7 @@ void EDA_VALUE_CTRL::SetValue( int new_value ) m_Value = new_value; - buffer = ReturnStringFromValue( m_UserUnit, m_Value, m_Internal_Unit ); + buffer = ReturnStringFromValue( m_UserUnit, m_Value ); m_ValueCtrl->SetValue( buffer ); } diff --git a/common/zoom.cpp b/common/zoom.cpp index cae1173461..0f0b6524f1 100644 --- a/common/zoom.cpp +++ b/common/zoom.cpp @@ -1,6 +1,30 @@ -/************/ -/* zoom.cpp */ -/************/ +/* + * This program source code file is part of KiCad, a free EDA CAD application. + * + * Copyright (C) 2004 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com + * Copyright (C) 1992-2011 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 zoom.cpp + */ /* * Manage zoom, grid step, and auto crop. @@ -15,6 +39,7 @@ #include #include #include +#include void EDA_DRAW_FRAME::RedrawScreen( const wxPoint& aCenterPoint, bool aWarpPointer ) @@ -198,8 +223,8 @@ void EDA_DRAW_FRAME::AddMenuZoomAndGrid( wxMenu* MasterMenu ) for( size_t i = 0; i < screen->GetGridCount(); i++ ) { tmp = screen->GetGrid( i ); - double gridValueInch = To_User_Unit( INCHES, tmp.m_Size.x, m_internalUnits ); - double gridValue_mm = To_User_Unit( MILLIMETRES, tmp.m_Size.x, m_internalUnits ); + double gridValueInch = To_User_Unit( INCHES, tmp.m_Size.x ); + double gridValue_mm = To_User_Unit( MILLIMETRES, tmp.m_Size.x ); if( tmp.m_Id == ID_POPUP_GRID_USER ) { diff --git a/eeschema/CMakeLists.txt b/eeschema/CMakeLists.txt index cfe73b36e3..e519f3cae1 100644 --- a/eeschema/CMakeLists.txt +++ b/eeschema/CMakeLists.txt @@ -162,6 +162,7 @@ set(EESCHEMA_COMMON_SRCS ../common/base_screen.cpp ../common/eda_text.cpp ../common/class_page_info.cpp + ../common/base_units.cpp ) diff --git a/eeschema/dialogs/dialog_SVG_print.cpp b/eeschema/dialogs/dialog_SVG_print.cpp index 3f205245bb..eb321d5e33 100644 --- a/eeschema/dialogs/dialog_SVG_print.cpp +++ b/eeschema/dialogs/dialog_SVG_print.cpp @@ -36,6 +36,8 @@ #include #include #include +#include + #include #include #include @@ -78,8 +80,7 @@ void DIALOG_SVG_PRINT::OnInitDialog( wxInitDialogEvent& event ) AddUnitSymbol( *m_TextPenWidth, g_UserUnit ); m_DialogPenWidth->SetValue( - ReturnStringFromValue( g_UserUnit, g_DrawDefaultLineThickness, - m_Parent->GetInternalUnits() ) ); + ReturnStringFromValue( g_UserUnit, g_DrawDefaultLineThickness ) ); m_Print_Sheet_Ref->SetValue( s_Print_Frame_Ref ); if( GetSizer() ) @@ -105,8 +106,7 @@ void DIALOG_SVG_PRINT::SetPenWidth() } m_DialogPenWidth->SetValue( - ReturnStringFromValue( g_UserUnit, g_DrawDefaultLineThickness, - m_Parent->GetInternalUnits() ) ); + ReturnStringFromValue( g_UserUnit, g_DrawDefaultLineThickness ) ); } diff --git a/eeschema/dialogs/dialog_edit_component_in_schematic.cpp b/eeschema/dialogs/dialog_edit_component_in_schematic.cpp index 0e6bd1f217..0c7d971884 100644 --- a/eeschema/dialogs/dialog_edit_component_in_schematic.cpp +++ b/eeschema/dialogs/dialog_edit_component_in_schematic.cpp @@ -11,6 +11,7 @@ #include #include #include +#include #include #include @@ -655,10 +656,10 @@ void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::copySelectedFieldToPanel() // top of each other. } - wxString coordText = ReturnStringFromValue( g_UserUnit, coord.x, EESCHEMA_INTERNAL_UNIT ); + wxString coordText = ReturnStringFromValue( g_UserUnit, coord.x ); posXTextCtrl->SetValue( coordText ); - coordText = ReturnStringFromValue( g_UserUnit, coord.y, EESCHEMA_INTERNAL_UNIT ); + coordText = ReturnStringFromValue( g_UserUnit, coord.y ); posYTextCtrl->SetValue( coordText ); } diff --git a/eeschema/dialogs/dialog_edit_label.cpp b/eeschema/dialogs/dialog_edit_label.cpp index 9f01bcdad1..189603ca60 100644 --- a/eeschema/dialogs/dialog_edit_label.cpp +++ b/eeschema/dialogs/dialog_edit_label.cpp @@ -31,6 +31,7 @@ #include #include #include +#include #include #include @@ -196,8 +197,7 @@ void DialogLabelEditor::InitDialog() msg = _( "H" ) + units + _( " x W" ) + units; m_staticSizeUnits->SetLabel( msg ); - msg = ReturnStringFromValue( g_UserUnit, m_CurrentText->m_Size.x, - m_Parent->GetInternalUnits() ); + msg = ReturnStringFromValue( g_UserUnit, m_CurrentText->m_Size.x ); m_TextSize->SetValue( msg ); if( m_CurrentText->Type() != SCH_GLOBAL_LABEL_T diff --git a/eeschema/dialogs/dialog_edit_libentry_fields_in_lib.cpp b/eeschema/dialogs/dialog_edit_libentry_fields_in_lib.cpp index 51f9fc2eeb..c1df45e904 100644 --- a/eeschema/dialogs/dialog_edit_libentry_fields_in_lib.cpp +++ b/eeschema/dialogs/dialog_edit_libentry_fields_in_lib.cpp @@ -10,6 +10,7 @@ #include #include #include +#include #include #include @@ -679,13 +680,13 @@ void DIALOG_EDIT_LIBENTRY_FIELDS_IN_LIB::copySelectedFieldToPanel() // top of each other. } - wxString coordText = ReturnStringFromValue( g_UserUnit, coord.x, EESCHEMA_INTERNAL_UNIT ); + wxString coordText = ReturnStringFromValue( g_UserUnit, coord.x ); posXTextCtrl->SetValue( coordText ); // Note: the Y axis for components in lib is from bottom to top // and the screen axis is top to bottom: we must change the y coord sign for editing NEGATE( coord.y ); - coordText = ReturnStringFromValue( g_UserUnit, coord.y, EESCHEMA_INTERNAL_UNIT ); + coordText = ReturnStringFromValue( g_UserUnit, coord.y ); posYTextCtrl->SetValue( coordText ); } diff --git a/eeschema/dialogs/dialog_edit_one_field.cpp b/eeschema/dialogs/dialog_edit_one_field.cpp index f7e1ab7f95..402f13557e 100644 --- a/eeschema/dialogs/dialog_edit_one_field.cpp +++ b/eeschema/dialogs/dialog_edit_one_field.cpp @@ -29,6 +29,7 @@ #include #include +#include #include #include @@ -52,8 +53,7 @@ void DIALOG_EDIT_ONE_FIELD::initDlg_base( ) m_CommonConvert->Show(false); m_CommonUnit->Show(false); - msg = ReturnStringFromValue( g_UserUnit, m_textsize, - m_parent->GetInternalUnits() ); + msg = ReturnStringFromValue( g_UserUnit, m_textsize ); m_TextSize->SetValue( msg ); if( m_textorient == TEXT_ORIENT_VERT ) diff --git a/eeschema/dialogs/dialog_lib_edit_text.cpp b/eeschema/dialogs/dialog_lib_edit_text.cpp index b2cc18c6d1..c37ef9e0a9 100644 --- a/eeschema/dialogs/dialog_lib_edit_text.cpp +++ b/eeschema/dialogs/dialog_lib_edit_text.cpp @@ -31,6 +31,7 @@ #include #include #include +#include #include #include @@ -63,8 +64,7 @@ void DIALOG_LIB_EDIT_TEXT::initDlg( ) if ( m_graphicText ) { - msg = ReturnStringFromValue( g_UserUnit, m_graphicText->m_Size.x, - m_parent->GetInternalUnits() ); + msg = ReturnStringFromValue( g_UserUnit, m_graphicText->m_Size.x ); m_TextSize->SetValue( msg ); m_TextValue->SetValue( m_graphicText->m_Text ); @@ -116,8 +116,7 @@ void DIALOG_LIB_EDIT_TEXT::initDlg( ) } else { - msg = ReturnStringFromValue( g_UserUnit, m_parent->m_textSize, - m_parent->GetInternalUnits() ); + msg = ReturnStringFromValue( g_UserUnit, m_parent->m_textSize ); m_TextSize->SetValue( msg ); if ( ! m_parent->m_drawSpecificUnit ) diff --git a/eeschema/dialogs/dialog_plot_schematic_HPGL.cpp b/eeschema/dialogs/dialog_plot_schematic_HPGL.cpp index a275610e64..f459b9d822 100644 --- a/eeschema/dialogs/dialog_plot_schematic_HPGL.cpp +++ b/eeschema/dialogs/dialog_plot_schematic_HPGL.cpp @@ -32,6 +32,7 @@ #include #include #include +#include #include #include @@ -148,7 +149,7 @@ void DIALOG_PLOT_SCHEMATIC_HPGL::initDlg() // Set validators m_SizeOption->SetSelection( s_pageSizeSelect ); AddUnitSymbol( *m_penWidthTitle, g_UserUnit ); - PutValueInLocalUnits( *m_penWidthCtrl, g_HPGL_Pen_Descr. m_Pen_Diam, EESCHEMA_INTERNAL_UNIT ); + PutValueInLocalUnits( *m_penWidthCtrl, g_HPGL_Pen_Descr. m_Pen_Diam ); m_penSpeedCtrl->SetValue( g_HPGL_Pen_Descr. m_Pen_Speed ); m_penNumCtrl->SetValue( g_HPGL_Pen_Descr. m_Pen_Num ); } @@ -179,15 +180,11 @@ void DIALOG_PLOT_SCHEMATIC_HPGL::SetPageOffsetValue() if( s_pageSizeSelect != PAGE_DEFAULT ) { - msg = ReturnStringFromValue( g_UserUnit, - s_Offset.x, - EESCHEMA_INTERNAL_UNIT ); + msg = ReturnStringFromValue( g_UserUnit, s_Offset.x ); m_PlotOrgPosition_X->SetValue( msg ); - msg = ReturnStringFromValue( g_UserUnit, - s_Offset.y, - EESCHEMA_INTERNAL_UNIT ); + msg = ReturnStringFromValue( g_UserUnit, s_Offset.y ); m_PlotOrgPosition_Y->SetValue( msg ); diff --git a/eeschema/dialogs/dialog_plot_schematic_PS.cpp b/eeschema/dialogs/dialog_plot_schematic_PS.cpp index b47487756d..1e8f8a2888 100644 --- a/eeschema/dialogs/dialog_plot_schematic_PS.cpp +++ b/eeschema/dialogs/dialog_plot_schematic_PS.cpp @@ -32,6 +32,7 @@ #include #include #include +#include #include #include @@ -115,8 +116,7 @@ void DIALOG_PLOT_SCHEMATIC_PS::initDlg() m_Plot_Sheet_Ref_Ctrl->SetValue( m_plot_Sheet_Ref ); AddUnitSymbol( *m_defaultLineWidthTitle, g_UserUnit ); - PutValueInLocalUnits( *m_DefaultLineSizeCtrl, - g_DrawDefaultLineThickness, EESCHEMA_INTERNAL_UNIT ); + PutValueInLocalUnits( *m_DefaultLineSizeCtrl, g_DrawDefaultLineThickness ); } diff --git a/eeschema/dialogs/dialog_print_using_printer.cpp b/eeschema/dialogs/dialog_print_using_printer.cpp index 21c85a7eab..7551f80e82 100644 --- a/eeschema/dialogs/dialog_print_using_printer.cpp +++ b/eeschema/dialogs/dialog_print_using_printer.cpp @@ -9,6 +9,7 @@ #include #include #include +#include #include #include diff --git a/eeschema/find.cpp b/eeschema/find.cpp index e8ff657fcb..764181e24d 100644 --- a/eeschema/find.cpp +++ b/eeschema/find.cpp @@ -40,6 +40,7 @@ #include #include #include +#include #include #include @@ -95,10 +96,8 @@ void SCH_EDIT_FRAME::OnFindDrcMarker( wxFindDialogEvent& event ) wxString path = sheetFoundIn->Path(); wxString units = GetAbbreviatedUnitsLabel(); - double x = To_User_Unit( g_UserUnit, (double) lastMarker->GetPosition().x, - m_internalUnits ); - double y = To_User_Unit( g_UserUnit, (double) lastMarker->GetPosition().y, - m_internalUnits ); + double x = To_User_Unit( g_UserUnit, (double) lastMarker->GetPosition().x ); + double y = To_User_Unit( g_UserUnit, (double) lastMarker->GetPosition().y ); msg.Printf( _( "Design rule check marker found in sheet %s at %0.3f%s, %0.3f%s" ), GetChars( path ), x, GetChars( units ), y, GetChars( units) ); SetStatusText( msg ); diff --git a/eeschema/lib_arc.cpp b/eeschema/lib_arc.cpp index 17007ca0ae..e9567fb0cb 100644 --- a/eeschema/lib_arc.cpp +++ b/eeschema/lib_arc.cpp @@ -34,6 +34,7 @@ #include #include #include +#include #include #include @@ -507,7 +508,7 @@ void LIB_ARC::DisplayInfo( EDA_DRAW_FRAME* aFrame ) LIB_ITEM::DisplayInfo( aFrame ); - msg = ReturnStringFromValue( g_UserUnit, m_Width, EESCHEMA_INTERNAL_UNIT, true ); + msg = ReturnStringFromValue( g_UserUnit, m_Width, true ); aFrame->AppendMsgPanel( _( "Line width" ), msg, BLUE ); @@ -521,9 +522,9 @@ void LIB_ARC::DisplayInfo( EDA_DRAW_FRAME* aFrame ) wxString LIB_ARC::GetSelectMenuText() const { return wxString::Format( _( "Arc center (%s, %s), radius %s" ), - GetChars( CoordinateToString( m_Pos.x, EESCHEMA_INTERNAL_UNIT ) ), - GetChars( CoordinateToString( m_Pos.y, EESCHEMA_INTERNAL_UNIT ) ), - GetChars( CoordinateToString( m_Radius, EESCHEMA_INTERNAL_UNIT ) ) ); + GetChars( CoordinateToString( m_Pos.x ) ), + GetChars( CoordinateToString( m_Pos.y ) ), + GetChars( CoordinateToString( m_Radius ) ) ); } diff --git a/eeschema/lib_bezier.cpp b/eeschema/lib_bezier.cpp index 0587b859bd..1c1bcc41dd 100644 --- a/eeschema/lib_bezier.cpp +++ b/eeschema/lib_bezier.cpp @@ -35,6 +35,7 @@ #include #include #include +#include #include #include @@ -410,7 +411,7 @@ void LIB_BEZIER::DisplayInfo( EDA_DRAW_FRAME* aFrame ) LIB_ITEM::DisplayInfo( aFrame ); - msg = ReturnStringFromValue( g_UserUnit, m_Width, EESCHEMA_INTERNAL_UNIT, true ); + msg = ReturnStringFromValue( g_UserUnit, m_Width, true ); aFrame->AppendMsgPanel( _( "Line width" ), msg, BLUE ); diff --git a/eeschema/lib_circle.cpp b/eeschema/lib_circle.cpp index 1c945c9a42..4c5032c17e 100644 --- a/eeschema/lib_circle.cpp +++ b/eeschema/lib_circle.cpp @@ -35,6 +35,7 @@ #include #include #include +#include #include #include @@ -270,11 +271,11 @@ void LIB_CIRCLE::DisplayInfo( EDA_DRAW_FRAME* aFrame ) LIB_ITEM::DisplayInfo( aFrame ); - msg = ReturnStringFromValue( g_UserUnit, m_Width, EESCHEMA_INTERNAL_UNIT, true ); + msg = ReturnStringFromValue( g_UserUnit, m_Width, true ); aFrame->AppendMsgPanel( _( "Line width" ), msg, BLUE ); - msg = ReturnStringFromValue( g_UserUnit, m_Radius, EESCHEMA_INTERNAL_UNIT, true ); + msg = ReturnStringFromValue( g_UserUnit, m_Radius, true ); aFrame->AppendMsgPanel( _( "Radius" ), msg, RED ); msg.Printf( wxT( "(%d, %d, %d, %d)" ), bBox.GetOrigin().x, @@ -287,9 +288,9 @@ void LIB_CIRCLE::DisplayInfo( EDA_DRAW_FRAME* aFrame ) wxString LIB_CIRCLE::GetSelectMenuText() const { return wxString::Format( _( "Circle center (%s, %s), radius %s" ), - GetChars( CoordinateToString( m_Pos.x, EESCHEMA_INTERNAL_UNIT ) ), - GetChars( CoordinateToString( m_Pos.y, EESCHEMA_INTERNAL_UNIT ) ), - GetChars( CoordinateToString( m_Radius, EESCHEMA_INTERNAL_UNIT ) ) ); + GetChars( CoordinateToString( m_Pos.x ) ), + GetChars( CoordinateToString( m_Pos.y ) ), + GetChars( CoordinateToString( m_Radius ) ) ); } diff --git a/eeschema/lib_field.cpp b/eeschema/lib_field.cpp index f8cb98ee6c..c3786e685a 100644 --- a/eeschema/lib_field.cpp +++ b/eeschema/lib_field.cpp @@ -36,6 +36,7 @@ #include #include #include +#include #include #include @@ -731,10 +732,10 @@ void LIB_FIELD::DisplayInfo( EDA_DRAW_FRAME* aFrame ) msg = GetTextStyleName(); aFrame->AppendMsgPanel( _( "Style" ), msg, MAGENTA ); - msg = ReturnStringFromValue( g_UserUnit, m_Size.x, EESCHEMA_INTERNAL_UNIT, true ); + msg = ReturnStringFromValue( g_UserUnit, m_Size.x, true ); aFrame->AppendMsgPanel( _( "Size X" ), msg, BLUE ); - msg = ReturnStringFromValue( g_UserUnit, m_Size.y, EESCHEMA_INTERNAL_UNIT, true ); + msg = ReturnStringFromValue( g_UserUnit, m_Size.y, true ); aFrame->AppendMsgPanel( _( "Size Y" ), msg, BLUE ); // Display field name (ref, value ...) diff --git a/eeschema/lib_pin.cpp b/eeschema/lib_pin.cpp index 6e56c01f7d..fa7c106b70 100644 --- a/eeschema/lib_pin.cpp +++ b/eeschema/lib_pin.cpp @@ -36,6 +36,7 @@ #include #include #include +#include #include #include @@ -1854,7 +1855,7 @@ void LIB_PIN::DisplayInfo( EDA_DRAW_FRAME* aFrame ) aFrame->AppendMsgPanel( _( "Visible" ), Text, DARKGREEN ); /* Display pin length */ - Text = ReturnStringFromValue( g_UserUnit, m_length, EESCHEMA_INTERNAL_UNIT, true ); + Text = ReturnStringFromValue( g_UserUnit, m_length, true ); aFrame->AppendMsgPanel( _( "Length" ), Text, MAGENTA ); Text = wxGetTranslation( pin_orientation_names[ GetOrientationCodeIndex( m_orientation ) ] ); diff --git a/eeschema/lib_polyline.cpp b/eeschema/lib_polyline.cpp index 3022fbb4c1..ca57fe87b9 100644 --- a/eeschema/lib_polyline.cpp +++ b/eeschema/lib_polyline.cpp @@ -34,6 +34,7 @@ #include #include #include +#include #include #include @@ -398,7 +399,7 @@ void LIB_POLYLINE::DisplayInfo( EDA_DRAW_FRAME* aFrame ) LIB_ITEM::DisplayInfo( aFrame ); - msg = ReturnStringFromValue( g_UserUnit, m_Width, EESCHEMA_INTERNAL_UNIT, true ); + msg = ReturnStringFromValue( g_UserUnit, m_Width, true ); aFrame->AppendMsgPanel( _( "Line width" ), msg, BLUE ); @@ -412,10 +413,8 @@ void LIB_POLYLINE::DisplayInfo( EDA_DRAW_FRAME* aFrame ) wxString LIB_POLYLINE::GetSelectMenuText() const { return wxString::Format( _( "Polyline at (%s, %s) with %u points" ), - GetChars( CoordinateToString( m_PolyPoints[0].x, - EESCHEMA_INTERNAL_UNIT ) ), - GetChars( CoordinateToString( m_PolyPoints[0].y, - EESCHEMA_INTERNAL_UNIT ) ), + GetChars( CoordinateToString( m_PolyPoints[0].x ) ), + GetChars( CoordinateToString( m_PolyPoints[0].y ) ), m_PolyPoints.size() ); } diff --git a/eeschema/lib_rectangle.cpp b/eeschema/lib_rectangle.cpp index bdab1b5f03..e06db81831 100644 --- a/eeschema/lib_rectangle.cpp +++ b/eeschema/lib_rectangle.cpp @@ -34,6 +34,7 @@ #include #include #include +#include #include #include @@ -248,7 +249,7 @@ void LIB_RECTANGLE::DisplayInfo( EDA_DRAW_FRAME* aFrame ) LIB_ITEM::DisplayInfo( aFrame ); - msg = ReturnStringFromValue( g_UserUnit, m_Width, EESCHEMA_INTERNAL_UNIT, true ); + msg = ReturnStringFromValue( g_UserUnit, m_Width, true ); aFrame->AppendMsgPanel( _( "Line width" ), msg, BLUE ); } @@ -324,10 +325,10 @@ bool LIB_RECTANGLE::HitTest( wxPoint aPosition, int aThreshold, const TRANSFORM& wxString LIB_RECTANGLE::GetSelectMenuText() const { return wxString::Format( _( "Rectangle from (%s, %s) to (%s, %s)" ), - GetChars( CoordinateToString( m_Pos.x, EESCHEMA_INTERNAL_UNIT ) ), - GetChars( CoordinateToString( m_Pos.y, EESCHEMA_INTERNAL_UNIT ) ), - GetChars( CoordinateToString( m_End.x, EESCHEMA_INTERNAL_UNIT ) ), - GetChars( CoordinateToString( m_End.y, EESCHEMA_INTERNAL_UNIT ) ) ); + GetChars( CoordinateToString( m_Pos.x ) ), + GetChars( CoordinateToString( m_Pos.y ) ), + GetChars( CoordinateToString( m_End.x ) ), + GetChars( CoordinateToString( m_End.y ) ) ); } diff --git a/eeschema/lib_text.cpp b/eeschema/lib_text.cpp index 349dc09889..b36f1c0cce 100644 --- a/eeschema/lib_text.cpp +++ b/eeschema/lib_text.cpp @@ -35,6 +35,7 @@ #include #include #include +#include #include #include @@ -413,7 +414,7 @@ void LIB_TEXT::DisplayInfo( EDA_DRAW_FRAME* frame ) LIB_ITEM::DisplayInfo( frame ); - msg = ReturnStringFromValue( g_UserUnit, m_Thickness, EESCHEMA_INTERNAL_UNIT, true ); + msg = ReturnStringFromValue( g_UserUnit, m_Thickness, true ); frame->AppendMsgPanel( _( "Line width" ), msg, BLUE ); } diff --git a/eeschema/pinedit.cpp b/eeschema/pinedit.cpp index 6449214ba5..e7da98dd30 100644 --- a/eeschema/pinedit.cpp +++ b/eeschema/pinedit.cpp @@ -33,6 +33,7 @@ #include #include #include +#include #include #include @@ -84,14 +85,10 @@ void LIB_EDIT_FRAME::OnEditPin( wxCommandEvent& event ) LIB_PIN::GetElectricalTypeSymbols() ); dlg.SetElectricalType( pin->GetType() ); dlg.SetName( pin->GetName() ); - dlg.SetNameTextSize( ReturnStringFromValue( g_UserUnit, - pin->GetNameTextSize(), - m_internalUnits ) ); + dlg.SetNameTextSize( ReturnStringFromValue( g_UserUnit, pin->GetNameTextSize() ) ); dlg.SetNameTextSizeUnits( units ); dlg.SetPadName( pin->GetNumberString() ); - dlg.SetPadNameTextSize( ReturnStringFromValue( g_UserUnit, - pin->GetNumberTextSize(), - m_internalUnits ) ); + dlg.SetPadNameTextSize( ReturnStringFromValue( g_UserUnit, pin->GetNumberTextSize() ) ); dlg.SetPadNameTextSizeUnits( units ); dlg.SetLength( ReturnStringFromValue( g_UserUnit, pin->GetLength(), m_internalUnits ) ); diff --git a/eeschema/sch_base_frame.cpp b/eeschema/sch_base_frame.cpp index 2954e054e7..265ee86e8c 100644 --- a/eeschema/sch_base_frame.cpp +++ b/eeschema/sch_base_frame.cpp @@ -25,6 +25,7 @@ #include #include #include +#include SCH_BASE_FRAME::SCH_BASE_FRAME( wxWindow* aParent, id_drawframe aWindowType, @@ -107,3 +108,69 @@ void SCH_BASE_FRAME::SetTitleBlock( const TITLE_BLOCK& aTitleBlock ) wxASSERT( GetScreen() ); GetScreen()->SetTitleBlock( aTitleBlock ); } + + +void SCH_BASE_FRAME::UpdateStatusBar() +{ + wxString line; + int dx, dy; + BASE_SCREEN* screen = GetScreen(); + + if( !screen ) + return; + + EDA_DRAW_FRAME::UpdateStatusBar(); + + // Display absolute coordinates: + double dXpos = To_User_Unit( g_UserUnit, screen->GetCrossHairPosition().x ); + double dYpos = To_User_Unit( g_UserUnit, screen->GetCrossHairPosition().y ); + + if ( g_UserUnit == MILLIMETRES ) + { + dXpos = RoundTo0( dXpos, 100.0 ); + dYpos = RoundTo0( dYpos, 100.0 ); + } + + wxString absformatter; + wxString locformatter; + + switch( g_UserUnit ) + { + case INCHES: + absformatter = wxT( "X %.3f Y %.3f" ); + locformatter = wxT( "dx %.3f dy %.3f d %.3f" ); + break; + + case MILLIMETRES: + absformatter = wxT( "X %.2f Y %.2f" ); + locformatter = wxT( "dx %.2f dy %.2f d %.2f" ); + break; + + case UNSCALED_UNITS: + absformatter = wxT( "X %f Y %f" ); + locformatter = wxT( "dx %f dy %f d %f" ); + break; + } + + line.Printf( absformatter, dXpos, dYpos ); + SetStatusText( line, 2 ); + + // Display relative coordinates: + dx = screen->GetCrossHairPosition().x - screen->m_O_Curseur.x; + dy = screen->GetCrossHairPosition().y - screen->m_O_Curseur.y; + dXpos = To_User_Unit( g_UserUnit, dx ); + dYpos = To_User_Unit( g_UserUnit, dy ); + + if( g_UserUnit == MILLIMETRES ) + { + dXpos = RoundTo0( dXpos, 100.0 ); + dYpos = RoundTo0( dYpos, 100.0 ); + } + + // We already decided the formatter above + line.Printf( locformatter, dXpos, dYpos, sqrt( dXpos * dXpos + dYpos * dYpos ) ); + SetStatusText( line, 3 ); + + // refresh units display + DisplayUnitsMsg(); +} diff --git a/eeschema/sch_line.cpp b/eeschema/sch_line.cpp index c9fddb6f6c..6e20f18fbe 100644 --- a/eeschema/sch_line.cpp +++ b/eeschema/sch_line.cpp @@ -34,6 +34,7 @@ #include #include #include +#include #include #include @@ -502,10 +503,10 @@ wxString SCH_LINE::GetSelectMenuText() const } menuText.Printf( txtfmt, GetChars( orient ), - GetChars(CoordinateToString( m_start.x, EESCHEMA_INTERNAL_UNIT )), - GetChars(CoordinateToString( m_start.y, EESCHEMA_INTERNAL_UNIT )), - GetChars(CoordinateToString( m_end.x, EESCHEMA_INTERNAL_UNIT )), - GetChars(CoordinateToString( m_end.y, EESCHEMA_INTERNAL_UNIT )) ); + GetChars( CoordinateToString( m_start.x ) ), + GetChars( CoordinateToString( m_start.y ) ), + GetChars( CoordinateToString( m_end.x ) ), + GetChars( CoordinateToString( m_end.y ) ) ); return menuText; } diff --git a/eeschema/sheet.cpp b/eeschema/sheet.cpp index 669060cb8c..149fef6578 100644 --- a/eeschema/sheet.cpp +++ b/eeschema/sheet.cpp @@ -31,6 +31,7 @@ #include #include #include +#include #include #include @@ -49,14 +50,10 @@ bool SCH_EDIT_FRAME::EditSheet( SCH_SHEET* aSheet, wxDC* aDC ) wxString units = GetUnitsLabel( g_UserUnit ); dlg.SetFileName( aSheet->GetFileName() ); - dlg.SetFileNameTextSize( ReturnStringFromValue( g_UserUnit, - aSheet->GetFileNameSize(), - m_internalUnits ) ); + dlg.SetFileNameTextSize( ReturnStringFromValue( g_UserUnit, aSheet->GetFileNameSize() ) ); dlg.SetFileNameTextSizeUnits( units ); dlg.SetSheetName( aSheet->GetName() ); - dlg.SetSheetNameTextSize( ReturnStringFromValue( g_UserUnit, - aSheet->GetSheetNameSize(), - m_internalUnits ) ); + dlg.SetSheetNameTextSize( ReturnStringFromValue( g_UserUnit, aSheet->GetSheetNameSize() ) ); dlg.SetSheetNameTextSizeUnits( units ); /* This ugly hack fixes a bug in wxWidgets 2.8.7 and likely earlier diff --git a/eeschema/sheetlab.cpp b/eeschema/sheetlab.cpp index 38661fe6ef..da16b9bae8 100644 --- a/eeschema/sheetlab.cpp +++ b/eeschema/sheetlab.cpp @@ -34,6 +34,7 @@ #include #include #include +#include #include #include @@ -56,9 +57,9 @@ int SCH_EDIT_FRAME::EditSheetPin( SCH_SHEET_PIN* aSheetPin, wxDC* aDC ) DIALOG_SCH_EDIT_SHEET_PIN dlg( this ); dlg.SetLabelName( aSheetPin->m_Text ); - dlg.SetTextHeight( ReturnStringFromValue( g_UserUnit, aSheetPin->m_Size.y, m_internalUnits ) ); + dlg.SetTextHeight( ReturnStringFromValue( g_UserUnit, aSheetPin->m_Size.y ) ); dlg.SetTextHeightUnits( GetUnitsLabel( g_UserUnit ) ); - dlg.SetTextWidth( ReturnStringFromValue( g_UserUnit, aSheetPin->m_Size.x, m_internalUnits ) ); + dlg.SetTextWidth( ReturnStringFromValue( g_UserUnit, aSheetPin->m_Size.x ) ); dlg.SetTextWidthUnits( GetUnitsLabel( g_UserUnit ) ); dlg.SetConnectionType( aSheetPin->GetShape() ); diff --git a/eeschema/symbdraw.cpp b/eeschema/symbdraw.cpp index 6936e18d68..68d9ac2dd9 100644 --- a/eeschema/symbdraw.cpp +++ b/eeschema/symbdraw.cpp @@ -33,6 +33,7 @@ #include #include #include +#include #include #include @@ -67,7 +68,7 @@ void LIB_EDIT_FRAME::EditGraphicSymbol( wxDC* DC, LIB_ITEM* DrawItem ) dialog.SetWidthUnits( ReturnUnitSymbol( g_UserUnit ) ); - wxString val = ReturnStringFromValue( g_UserUnit, m_drawLineWidth, m_internalUnits ); + wxString val = ReturnStringFromValue( g_UserUnit, m_drawLineWidth ); dialog.SetWidth( val ); dialog.SetApplyToAllUnits( !m_drawSpecificUnit ); dialog.EnableApplyToAllUnits( component && component->GetPartCount() > 1 ); diff --git a/include/base_units.h b/include/base_units.h new file mode 100644 index 0000000000..06374608cb --- /dev/null +++ b/include/base_units.h @@ -0,0 +1,83 @@ +/* + * This program source code file is part of KiCad, a free EDA CAD application. + * + * Copyright (C) 2012 CERN + * Copyright (C) 1992-2011 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 + */ + +/** + * @author Wayne Stambaugh + * @file base_units.h + * @brief Implementation of conversion functions that require both schematic and board + * internal units. + */ + +#ifndef _BASE_UNITS_H_ +#define _BASE_UNITS_H_ + + +#include + + +/** + * Function To_User_Unit + * convert \a aValue in internal units to the appropriate user units defined by \a aUnit. + * + * @return The converted value, in double + * @param aUnit The units to convert \a aValue to. + * @param aValue The value in internal units to convert. + */ +double To_User_Unit( EDA_UNITS_T aUnit, double aValue ); + +/** + * Function CoordinateToString + * is a helper to convert the integer coordinate \a aValue to a string in inches, + * millimeters, or unscaled units according to the current user units setting. + * + * @param aValue The coordinate to convert. + * @param aConvertToMils Convert inch values to mils if true. This setting has no effect if + * the current user unit is millimeters. + * @return The converted string for display in user interface elements. + */ +wxString CoordinateToString( int aValue, bool aConvertToMils = false ); + + +/** + * Function ReturnStringFromValue + * returns the string from \a aValue according to units (inch, mm ...) for display, + * and the initial unit for value. + * @param aUnit = display units (INCHES, MILLIMETRE ..) + * @param aValue = value in Internal_Unit + * @param aAddUnitSymbol = true to add symbol unit to the string value + * @return A wxString object containing value and optionally the symbol unit (like 2.000 mm) + */ +wxString ReturnStringFromValue( EDA_UNITS_T aUnit, int aValue, bool aAddUnitSymbol = false ); + +/** + * Function PutValueInLocalUnits + * converts \a aValue from internal units to user units and append the units notation + * (mm or ")then inserts the string an \a aTextCtrl. + * + * This function is used in dialog boxes for entering values depending on selected units. + */ +void PutValueInLocalUnits( wxTextCtrl& aTextCtr, int aValue ); + +#endif // _BASE_UNITS_H_ diff --git a/include/common.h b/include/common.h index f1cc46e354..5952c13635 100644 --- a/include/common.h +++ b/include/common.h @@ -530,20 +530,6 @@ int GetCommandOptions( const int argc, const char** argv, */ const wxString& valeur_param( int valeur, wxString& buf_texte ); -/** - * Function CoordinateToString - * is a helper to convert the integer coordinate \a aValue to a string in inches, - * millimeters, or unscaled units according to the current user units setting. - * - * @param aValue The coordinate to convert. - * @param aInternalUnits The internal units of the application. #EESCHEMA_INTERNAL_UNIT - * and #PCB_INTERNAL_UNIT are the only valid value. - * @param aConvertToMils Convert inch values to mils if true. This setting has no effect if - * the current user unit is millimeters. - * @return The converted string for display in user interface elements. - */ -wxString CoordinateToString( int aValue, int aInternalUnits, bool aConvertToMils = false ); - /** * Returns the units symbol. * @@ -577,34 +563,22 @@ wxString GetAbbreviatedUnitsLabel( EDA_UNITS_T aUnit = g_UserUnit ); */ int ReturnValueFromString( EDA_UNITS_T aUnit, const wxString& TextValue, int Internal_Unit ); -/** - * Function ReturnStringFromValue - * Return the string from Value, according to units (inch, mm ...) for display, - * and the initial unit for value - * @param aUnit = display units (INCHES, MILLIMETRE ..) - * @param aValue = value in Internal_Unit - * @param aInternal_Unit = units per inch for Value - * @param aAdd_unit_symbol = true to add symbol unit to the string value - * @return a wxString what contains value and optionally the symbol unit (like - * 2.000 mm) - */ -wxString ReturnStringFromValue( EDA_UNITS_T aUnit, - int aValue, - int aInternal_Unit, - bool aAdd_unit_symbol = false ); - -void AddUnitSymbol( wxStaticText& Stext, EDA_UNITS_T aUnit = g_UserUnit ); - -/* Add string " (mm):" or " ("):" to the static text Stext. - * Used in dialog boxes for entering values depending on selected units */ -void PutValueInLocalUnits( wxTextCtrl& TextCtr, int Value, - int Internal_Unit ); +void AddUnitSymbol( wxStaticText& Stext, EDA_UNITS_T aUnit = g_UserUnit ); /* Convert the number Value in a string according to the internal units * and the selected unit (g_UserUnit) and put it in the wxTextCtrl TextCtrl **/ -int ReturnValueFromTextCtrl( const wxTextCtrl& TextCtr, - int Internal_Unit ); +int ReturnValueFromTextCtrl( const wxTextCtrl& TextCtr, int Internal_Unit ); + +/** + * Round to the nearest precision. + * + * Try to approximate a coordinate using a given precision to prevent + * rounding errors when converting from inches to mm. + * + * ie round the unit value to 0 if unit is 1 or 2, or 8 or 9 + */ +double RoundTo0( double x, double precision ); /** * Function wxStringSplit @@ -615,17 +589,6 @@ int ReturnValueFromTextCtrl( const wxTextCtrl& TextCtr, */ wxArrayString* wxStringSplit( wxString aString, wxChar aSplitter ); -/** - * Function To_User_Unit - * Convert in inch or mm the variable "val" (double)given in internal units - * @return the converted value, in double - * @param aUnit : user unit to be converted to - * @param val : double : the given value - - * @param internal_unit_value = internal units per inch - */ -double To_User_Unit( EDA_UNITS_T aUnit, double val, int internal_unit_value ); - /** * Return in internal units the value "val" given in inch or mm */ diff --git a/include/sch_base_frame.h b/include/sch_base_frame.h index 33f02c9c9b..41efe6842e 100644 --- a/include/sch_base_frame.h +++ b/include/sch_base_frame.h @@ -76,6 +76,8 @@ public: const TITLE_BLOCK& GetTitleBlock() const; // overload EDA_DRAW_FRAME void SetTitleBlock( const TITLE_BLOCK& aTitleBlock ); // overload EDA_DRAW_FRAME + void UpdateStatusBar(); // overload EDA_DRAW_FRAME + protected: /** diff --git a/pcbnew/basepcbframe.cpp b/pcbnew/basepcbframe.cpp index 7b189a1575..3f0713e4e8 100644 --- a/pcbnew/basepcbframe.cpp +++ b/pcbnew/basepcbframe.cpp @@ -35,6 +35,7 @@ #include #include #include +#include #include #include @@ -78,7 +79,7 @@ PCB_BASE_FRAME::PCB_BASE_FRAME( wxWindow* father, const wxString& title, const wxPoint& pos, const wxSize& size, - long style) : + long style) : EDA_DRAW_FRAME( father, idtype, title, pos, size, style ) { m_internalUnits = PCB_INTERNAL_UNIT; // Internal unit = 1/10000 inch @@ -552,18 +553,24 @@ void PCB_BASE_FRAME::UpdateStatusBar() { EDA_DRAW_FRAME::UpdateStatusBar(); + PCB_SCREEN* screen = GetScreen(); + + if( !screen ) + return; + + int dx; + int dy; + double dXpos; + double dYpos; + wxString line; + wxString locformatter; + if( DisplayOpt.DisplayPolarCood ) // display polar coordinates { - PCB_SCREEN* screen = GetScreen(); - - if( !screen ) - return; - - wxString Line; double theta, ro; - int dx = screen->GetCrossHairPosition().x - screen->m_O_Curseur.x; - int dy = screen->GetCrossHairPosition().y - screen->m_O_Curseur.y; + dx = screen->GetCrossHairPosition().x - screen->m_O_Curseur.x; + dy = screen->GetCrossHairPosition().y - screen->m_O_Curseur.y; if( dx==0 && dy==0 ) theta = 0.0; @@ -589,11 +596,62 @@ void PCB_BASE_FRAME::UpdateStatusBar() break; } - Line.Printf( formatter, To_User_Unit( g_UserUnit, ro, m_internalUnits ), theta ); + line.Printf( formatter, To_User_Unit( g_UserUnit, ro ), theta ); - // overwrite the absolute cartesian coordinates - SetStatusText( Line, 2 ); + SetStatusText( line, 2 ); } + else + { + // Display absolute coordinates: + dXpos = To_User_Unit( g_UserUnit, screen->GetCrossHairPosition().x ); + dYpos = To_User_Unit( g_UserUnit, screen->GetCrossHairPosition().y ); + + if ( g_UserUnit == MILLIMETRES ) + { + dXpos = RoundTo0( dXpos, 1000.0 ); + dYpos = RoundTo0( dYpos, 1000.0 ); + } + + // The following sadly is an if Eeschema/if Pcbnew + wxString absformatter; + + switch( g_UserUnit ) + { + case INCHES: + absformatter = wxT( "X %.4f Y %.4f" ); + locformatter = wxT( "dx %.4f dy %.4f d %.4f" ); + break; + + case MILLIMETRES: + absformatter = wxT( "X %.3f Y %.3f" ); + locformatter = wxT( "dx %.3f dy %.3f d %.3f" ); + break; + + case UNSCALED_UNITS: + absformatter = wxT( "X %f Y %f" ); + locformatter = wxT( "dx %f dy %f d %f" ); + break; + } + + line.Printf( absformatter, dXpos, dYpos ); + SetStatusText( line, 2 ); + } + + // Display relative coordinates: + dx = screen->GetCrossHairPosition().x - screen->m_O_Curseur.x; + dy = screen->GetCrossHairPosition().y - screen->m_O_Curseur.y; + dXpos = To_User_Unit( g_UserUnit, dx ); + dYpos = To_User_Unit( g_UserUnit, dy ); + + if ( g_UserUnit == MILLIMETRES ) + { + dXpos = RoundTo0( dXpos, 1000.0 ); + dYpos = RoundTo0( dYpos, 1000.0 ); + } + + // We already decided the formatter above + line.Printf( locformatter, dXpos, dYpos, sqrt( dXpos * dXpos + dYpos * dYpos ) ); + SetStatusText( line, 3 ); } @@ -711,7 +769,7 @@ void PCB_BASE_FRAME::updateGridSelectBox() for( size_t i = 0; i < GetScreen()->GetGridCount(); i++ ) { GRID_TYPE& grid = GetScreen()->GetGrid( i ); - double value = To_User_Unit( g_UserUnit, grid.m_Size.x, m_internalUnits ); + double value = To_User_Unit( g_UserUnit, grid.m_Size.x ); if( grid.m_Id != ID_POPUP_GRID_USER ) { diff --git a/pcbnew/dialogs/dialog_SVG_print.cpp b/pcbnew/dialogs/dialog_SVG_print.cpp index 93d708dddc..863b149bd6 100644 --- a/pcbnew/dialogs/dialog_SVG_print.cpp +++ b/pcbnew/dialogs/dialog_SVG_print.cpp @@ -15,6 +15,7 @@ #include #include #include +#include #include #include @@ -70,8 +71,7 @@ void DIALOG_SVG_PRINT::initDialog( ) s_Parameters.m_PenDefaultSize = g_DrawDefaultLineThickness; AddUnitSymbol( *m_TextPenWidth, g_UserUnit ); m_DialogPenWidth->SetValue( - ReturnStringFromValue( g_UserUnit, s_Parameters.m_PenDefaultSize, - m_Parent->GetInternalUnits() ) ); + ReturnStringFromValue( g_UserUnit, s_Parameters.m_PenDefaultSize ) ); m_Print_Frame_Ref_Ctrl->SetValue( s_Parameters.m_Print_Sheet_Ref ); @@ -150,8 +150,7 @@ void DIALOG_SVG_PRINT::SetPenWidth() g_DrawDefaultLineThickness = s_Parameters.m_PenDefaultSize; m_DialogPenWidth->SetValue( - ReturnStringFromValue( g_UserUnit, s_Parameters.m_PenDefaultSize, - m_Parent->GetInternalUnits() ) ); + ReturnStringFromValue( g_UserUnit, s_Parameters.m_PenDefaultSize ) ); } diff --git a/pcbnew/dialogs/dialog_copper_zones.cpp b/pcbnew/dialogs/dialog_copper_zones.cpp index 666b8bc868..252654a6ef 100644 --- a/pcbnew/dialogs/dialog_copper_zones.cpp +++ b/pcbnew/dialogs/dialog_copper_zones.cpp @@ -15,6 +15,7 @@ #include #include #include +#include #include #include @@ -178,15 +179,11 @@ void DIALOG_COPPER_ZONE::initDialog() m_FillModeCtrl->SetSelection( m_settings.m_FillMode ? 1 : 0 ); AddUnitSymbol( *m_ClearanceValueTitle, g_UserUnit ); - msg = ReturnStringFromValue( g_UserUnit, - m_settings.m_ZoneClearance, - m_Parent->GetInternalUnits() ); + msg = ReturnStringFromValue( g_UserUnit, m_settings.m_ZoneClearance ); m_ZoneClearanceCtrl->SetValue( msg ); AddUnitSymbol( *m_MinThicknessValueTitle, g_UserUnit ); - msg = ReturnStringFromValue( g_UserUnit, - m_settings.m_ZoneMinThickness, - m_Parent->GetInternalUnits() ); + msg = ReturnStringFromValue( g_UserUnit, m_settings.m_ZoneMinThickness ); m_ZoneMinThicknessCtrl->SetValue( msg ); switch( m_settings.GetPadConnection() ) @@ -220,18 +217,12 @@ void DIALOG_COPPER_ZONE::initDialog() AddUnitSymbol( *m_AntipadSizeText, g_UserUnit ); AddUnitSymbol( *m_CopperBridgeWidthText, g_UserUnit ); - PutValueInLocalUnits( *m_AntipadSizeValue, - m_settings.m_ThermalReliefGap, - PCB_INTERNAL_UNIT ); - PutValueInLocalUnits( *m_CopperWidthValue, - m_settings.m_ThermalReliefCopperBridge, - PCB_INTERNAL_UNIT ); + PutValueInLocalUnits( *m_AntipadSizeValue, m_settings.m_ThermalReliefGap ); + PutValueInLocalUnits( *m_CopperWidthValue, m_settings.m_ThermalReliefCopperBridge ); m_cornerSmoothingChoice->SetSelection( m_settings.GetCornerSmoothingType() ); - PutValueInLocalUnits( *m_cornerSmoothingCtrl, - m_settings.GetCornerRadius(), - PCB_INTERNAL_UNIT ); + PutValueInLocalUnits( *m_cornerSmoothingCtrl, m_settings.GetCornerRadius() ); switch( m_settings.m_Zone_HatchingStyle ) { diff --git a/pcbnew/dialogs/dialog_design_rules.cpp b/pcbnew/dialogs/dialog_design_rules.cpp index cd5b6ba2f2..1913f65438 100644 --- a/pcbnew/dialogs/dialog_design_rules.cpp +++ b/pcbnew/dialogs/dialog_design_rules.cpp @@ -33,6 +33,7 @@ #include #include #include +#include #include #include @@ -207,26 +208,19 @@ DIALOG_DESIGN_RULES::DIALOG_DESIGN_RULES( PCB_EDIT_FRAME* parent ) : void DIALOG_DESIGN_RULES::PrintCurrentSettings() { wxString msg, value; - int internal_units = m_Parent->GetInternalUnits(); m_MessagesList->AppendToPage( _( "Current general settings:
" ) ); // Display min values: - value = ReturnStringFromValue( g_UserUnit, - m_BrdSettings.m_TrackMinWidth, - internal_units, - true ); + value = ReturnStringFromValue( g_UserUnit, m_BrdSettings.m_TrackMinWidth, true ); msg.Printf( _( "Minimum value for tracks width: %s
\n" ), GetChars( value ) ); m_MessagesList->AppendToPage( msg ); - value = ReturnStringFromValue( g_UserUnit, m_BrdSettings.m_ViasMinSize, internal_units, true ); + value = ReturnStringFromValue( g_UserUnit, m_BrdSettings.m_ViasMinSize, true ); msg.Printf( _( "Minimum value for vias diameter: %s
\n" ), GetChars( value ) ); m_MessagesList->AppendToPage( msg ); - value = ReturnStringFromValue( g_UserUnit, - m_BrdSettings.m_MicroViasMinSize, - internal_units, - true ); + value = ReturnStringFromValue( g_UserUnit, m_BrdSettings.m_MicroViasMinSize, true ); msg.Printf( _( "Minimum value for microvias diameter: %s
\n" ), GetChars( value ) ); m_MessagesList->AppendToPage( msg ); } @@ -290,22 +284,16 @@ void DIALOG_DESIGN_RULES::InitGlobalRules() AddUnitSymbol( *m_MicroViaMinDrillTitle ); AddUnitSymbol( *m_TrackMinWidthTitle ); - int Internal_Unit = m_Parent->GetInternalUnits(); - PutValueInLocalUnits( *m_SetViasMinSizeCtrl, m_BrdSettings.m_ViasMinSize, Internal_Unit ); - PutValueInLocalUnits( *m_SetViasMinDrillCtrl, m_BrdSettings.m_ViasMinDrill, Internal_Unit ); + PutValueInLocalUnits( *m_SetViasMinSizeCtrl, m_BrdSettings.m_ViasMinSize ); + PutValueInLocalUnits( *m_SetViasMinDrillCtrl, m_BrdSettings.m_ViasMinDrill ); if( m_BrdSettings.m_CurrentViaType != VIA_THROUGH ) m_OptViaType->SetSelection( 1 ); m_AllowMicroViaCtrl->SetSelection( m_BrdSettings.m_MicroViasAllowed ? 1 : 0 ); - PutValueInLocalUnits( *m_SetMicroViasMinSizeCtrl, - m_BrdSettings.m_MicroViasMinSize, - Internal_Unit ); - PutValueInLocalUnits( *m_SetMicroViasMinDrillCtrl, - m_BrdSettings.m_MicroViasMinDrill, - Internal_Unit ); - - PutValueInLocalUnits( *m_SetTrackMinWidthCtrl, m_BrdSettings.m_TrackMinWidth, Internal_Unit ); + PutValueInLocalUnits( *m_SetMicroViasMinSizeCtrl, m_BrdSettings.m_MicroViasMinSize ); + PutValueInLocalUnits( *m_SetMicroViasMinDrillCtrl, m_BrdSettings.m_MicroViasMinDrill ); + PutValueInLocalUnits( *m_SetTrackMinWidthCtrl, m_BrdSettings.m_TrackMinWidth ); // Initialize Vias and Tracks sizes lists. // note we display only extra values, never the current netclass value. @@ -326,7 +314,6 @@ void DIALOG_DESIGN_RULES::InitDimensionsLists() */ { wxString msg; - int Internal_Unit = m_Parent->GetInternalUnits(); // Compute the column widths here, after setting texts msg = wxT("000000.000000"); // This is a very long text to display values. @@ -347,19 +334,17 @@ void DIALOG_DESIGN_RULES::InitDimensionsLists() for( unsigned ii = 0; ii < m_TracksWidthList.size(); ii++ ) { - msg = ReturnStringFromValue( g_UserUnit, m_TracksWidthList[ii], Internal_Unit, false ); + msg = ReturnStringFromValue( g_UserUnit, m_TracksWidthList[ii], false ); m_gridTrackWidthList->SetCellValue( ii, 0, msg ); } for( unsigned ii = 0; ii < m_ViasDimensionsList.size(); ii++ ) { - msg = ReturnStringFromValue( g_UserUnit, m_ViasDimensionsList[ii].m_Diameter, - Internal_Unit, false ); + msg = ReturnStringFromValue( g_UserUnit, m_ViasDimensionsList[ii].m_Diameter, false ); m_gridViaSizeList->SetCellValue( ii, 0, msg ); if( m_ViasDimensionsList[ii].m_Drill > 0 ) { - msg = ReturnStringFromValue( g_UserUnit, m_ViasDimensionsList[ii].m_Drill, - Internal_Unit, false ); + msg = ReturnStringFromValue( g_UserUnit, m_ViasDimensionsList[ii].m_Drill, false ); m_gridViaSizeList->SetCellValue( ii, 1, msg ); } } @@ -495,22 +480,22 @@ static void class2gridRow( wxGrid* grid, int row, NETCLASS* nc, int units ) // label is netclass name grid->SetRowLabelValue( row, nc->GetName() ); - msg = ReturnStringFromValue( g_UserUnit, nc->GetClearance(), units ); + msg = ReturnStringFromValue( g_UserUnit, nc->GetClearance() ); grid->SetCellValue( row, GRID_CLEARANCE, msg ); - msg = ReturnStringFromValue( g_UserUnit, nc->GetTrackWidth(), units ); + msg = ReturnStringFromValue( g_UserUnit, nc->GetTrackWidth() ); grid->SetCellValue( row, GRID_TRACKSIZE, msg ); - msg = ReturnStringFromValue( g_UserUnit, nc->GetViaDiameter(), units ); + msg = ReturnStringFromValue( g_UserUnit, nc->GetViaDiameter() ); grid->SetCellValue( row, GRID_VIASIZE, msg ); - msg = ReturnStringFromValue( g_UserUnit, nc->GetViaDrill(), units ); + msg = ReturnStringFromValue( g_UserUnit, nc->GetViaDrill() ); grid->SetCellValue( row, GRID_VIADRILL, msg ); - msg = ReturnStringFromValue( g_UserUnit, nc->GetuViaDiameter(), units ); + msg = ReturnStringFromValue( g_UserUnit, nc->GetuViaDiameter() ); grid->SetCellValue( row, GRID_uVIASIZE, msg ); - msg = ReturnStringFromValue( g_UserUnit, nc->GetuViaDrill(), units ); + msg = ReturnStringFromValue( g_UserUnit, nc->GetuViaDrill() ); grid->SetCellValue( row, GRID_uVIADRILL, msg ); } diff --git a/pcbnew/dialogs/dialog_edit_module_for_BoardEditor.cpp b/pcbnew/dialogs/dialog_edit_module_for_BoardEditor.cpp index bab2d056a9..3c7652aea8 100644 --- a/pcbnew/dialogs/dialog_edit_module_for_BoardEditor.cpp +++ b/pcbnew/dialogs/dialog_edit_module_for_BoardEditor.cpp @@ -12,6 +12,7 @@ #include <3d_struct.h> #include <3d_viewer.h> #include +#include #include #include @@ -62,12 +63,10 @@ DIALOG_MODULE_BOARD_EDITOR::~DIALOG_MODULE_BOARD_EDITOR() /* Creation of the panel properties of the module editor. */ void DIALOG_MODULE_BOARD_EDITOR::InitBoardProperties() { - PutValueInLocalUnits( *m_ModPositionX, - m_CurrentModule->GetPosition().x, PCB_INTERNAL_UNIT ); + PutValueInLocalUnits( *m_ModPositionX, m_CurrentModule->GetPosition().x ); AddUnitSymbol( *XPositionStatic, g_UserUnit ); - PutValueInLocalUnits( *m_ModPositionY, - m_CurrentModule->GetPosition().y, PCB_INTERNAL_UNIT ); + PutValueInLocalUnits( *m_ModPositionY, m_CurrentModule->GetPosition().y ); AddUnitSymbol( *YPositionStatic, g_UserUnit ); m_LayerCtrl->SetSelection( @@ -111,18 +110,13 @@ void DIALOG_MODULE_BOARD_EDITOR::InitBoardProperties() m_SolderMaskMarginUnits->SetLabel( GetUnitsLabel( g_UserUnit ) ); m_SolderPasteMarginUnits->SetLabel( GetUnitsLabel( g_UserUnit ) ); - int internalUnit = m_Parent->GetInternalUnits(); - PutValueInLocalUnits( *m_NetClearanceValueCtrl, - m_CurrentModule->m_LocalClearance, internalUnit ); - PutValueInLocalUnits( *m_SolderMaskMarginCtrl, - m_CurrentModule->m_LocalSolderMaskMargin, - internalUnit ); + PutValueInLocalUnits( *m_NetClearanceValueCtrl, m_CurrentModule->m_LocalClearance ); + PutValueInLocalUnits( *m_SolderMaskMarginCtrl, m_CurrentModule->m_LocalSolderMaskMargin ); // These 2 parameters are usually < 0, so prepare entering a negative // value, if current is 0 - PutValueInLocalUnits( *m_SolderPasteMarginCtrl, - m_CurrentModule->GetLocalSolderPasteMargin(), - internalUnit ); + PutValueInLocalUnits( *m_SolderPasteMarginCtrl, m_CurrentModule->GetLocalSolderPasteMargin() ); + if( m_CurrentModule->GetLocalSolderPasteMargin() == 0 ) m_SolderPasteMarginCtrl->SetValue( wxT( "-" ) + m_SolderPasteMarginCtrl->GetValue() ); diff --git a/pcbnew/dialogs/dialog_edit_module_for_Modedit.cpp b/pcbnew/dialogs/dialog_edit_module_for_Modedit.cpp index 3274aa7abb..7b78f02849 100644 --- a/pcbnew/dialogs/dialog_edit_module_for_Modedit.cpp +++ b/pcbnew/dialogs/dialog_edit_module_for_Modedit.cpp @@ -11,6 +11,7 @@ #include <3d_struct.h> #include <3d_viewer.h> #include +#include #include #include @@ -148,20 +149,19 @@ void DIALOG_MODULE_MODULE_EDITOR::InitModeditProperties() m_SolderPasteMarginUnits->SetLabel( GetUnitsLabel( g_UserUnit ) ); wxString msg; - int internalUnit = m_Parent->GetInternalUnits(); - PutValueInLocalUnits( *m_NetClearanceValueCtrl, - m_CurrentModule->m_LocalClearance, internalUnit ); - PutValueInLocalUnits( *m_SolderMaskMarginCtrl, - m_CurrentModule->m_LocalSolderMaskMargin, internalUnit ); + PutValueInLocalUnits( *m_NetClearanceValueCtrl, m_CurrentModule->m_LocalClearance ); + PutValueInLocalUnits( *m_SolderMaskMarginCtrl, m_CurrentModule->m_LocalSolderMaskMargin ); // These 2 parameters are usually < 0, so prepare entering a negative value, if current is 0 - PutValueInLocalUnits( *m_SolderPasteMarginCtrl, - m_CurrentModule->GetLocalSolderPasteMargin(), internalUnit ); + PutValueInLocalUnits( *m_SolderPasteMarginCtrl, m_CurrentModule->GetLocalSolderPasteMargin() ); + if( m_CurrentModule->GetLocalSolderPasteMargin() == 0 ) m_SolderPasteMarginCtrl->SetValue( wxT("-") + m_SolderPasteMarginCtrl->GetValue() ); + if( m_CurrentModule->GetLocalSolderPasteMarginRatio() == 0.0 ) msg.Printf( wxT( "-%.1f" ), m_CurrentModule->GetLocalSolderPasteMarginRatio() * 100.0 ); else msg.Printf( wxT( "%.1f" ), m_CurrentModule->GetLocalSolderPasteMarginRatio() * 100.0 ); + m_SolderPasteMarginRatioCtrl->SetValue( msg ); // if m_3D_ShapeNameListBox is not empty, preselect first 3D shape diff --git a/pcbnew/dialogs/dialog_edit_module_text.cpp b/pcbnew/dialogs/dialog_edit_module_text.cpp index e6a7526036..41b68095c9 100644 --- a/pcbnew/dialogs/dialog_edit_module_text.cpp +++ b/pcbnew/dialogs/dialog_edit_module_text.cpp @@ -14,6 +14,7 @@ #include #include #include +#include #include #include @@ -118,24 +119,19 @@ void DialogEditModuleText::initDlg( ) m_Style->SetSelection( m_currentText->m_Italic ? 1 : 0 ); AddUnitSymbol( *m_SizeXTitle ); - PutValueInLocalUnits( *m_TxtSizeCtrlX, m_currentText->m_Size.x, - m_parent->GetInternalUnits() ); + PutValueInLocalUnits( *m_TxtSizeCtrlX, m_currentText->m_Size.x ); AddUnitSymbol( *m_SizeYTitle ); - PutValueInLocalUnits( *m_TxtSizeCtrlY, m_currentText->m_Size.y, - m_parent->GetInternalUnits() ); + PutValueInLocalUnits( *m_TxtSizeCtrlY, m_currentText->m_Size.y ); AddUnitSymbol( *m_PosXTitle ); - PutValueInLocalUnits( *m_TxtPosCtrlX, m_currentText->GetPos0().x, - m_parent->GetInternalUnits() ); + PutValueInLocalUnits( *m_TxtPosCtrlX, m_currentText->GetPos0().x ); AddUnitSymbol( *m_PosYTitle ); - PutValueInLocalUnits( *m_TxtPosCtrlY, m_currentText->GetPos0().y, - m_parent->GetInternalUnits() ); + PutValueInLocalUnits( *m_TxtPosCtrlY, m_currentText->GetPos0().y ); AddUnitSymbol( *m_WidthTitle ); - PutValueInLocalUnits( *m_TxtWidthCtlr, m_currentText->m_Thickness, - m_parent->GetInternalUnits() ); + PutValueInLocalUnits( *m_TxtWidthCtlr, m_currentText->m_Thickness ); int text_orient = m_currentText->m_Orient; NORMALIZE_ANGLE_90(text_orient) diff --git a/pcbnew/dialogs/dialog_global_edit_tracks_and_vias.cpp b/pcbnew/dialogs/dialog_global_edit_tracks_and_vias.cpp index dfeb05fc6d..7533481ab1 100644 --- a/pcbnew/dialogs/dialog_global_edit_tracks_and_vias.cpp +++ b/pcbnew/dialogs/dialog_global_edit_tracks_and_vias.cpp @@ -10,6 +10,7 @@ #include #include #include +#include #include @@ -44,7 +45,6 @@ void DIALOG_GLOBAL_EDIT_TRACKS_AND_VIAS::MyInit() wxString msg; // Display current setup for tracks and vias - int Internal_Unit = m_Parent->GetInternalUnits(); BOARD* board = m_Parent->GetBoard(); NETCLASSES& netclasses = board->m_NetClasses; NETINFO_ITEM* net = board->FindNet( m_Netcode ); @@ -73,56 +73,56 @@ void DIALOG_GLOBAL_EDIT_TRACKS_AND_VIAS::MyInit() // Display current values, and current netclass values: int value = netclass->GetTrackWidth(); // Display track width - msg = ReturnStringFromValue( g_UserUnit, value, Internal_Unit, true ); + msg = ReturnStringFromValue( g_UserUnit, value, true ); m_gridDisplayCurrentSettings->SetCellValue( 0, 0, msg ); if( board->m_TrackWidthSelector ) { value = board->GetCurrentTrackWidth(); - msg = ReturnStringFromValue( g_UserUnit, value, Internal_Unit, true ); + msg = ReturnStringFromValue( g_UserUnit, value, true ); } else msg = _( "Default" ); m_gridDisplayCurrentSettings->SetCellValue( 1, 0, msg ); value = netclass->GetViaDiameter(); // Display via diameter - msg = ReturnStringFromValue( g_UserUnit, value, Internal_Unit, true ); + msg = ReturnStringFromValue( g_UserUnit, value, true ); m_gridDisplayCurrentSettings->SetCellValue( 0, 1, msg ); if( board->m_ViaSizeSelector ) { value = board->GetCurrentViaSize(); - msg = ReturnStringFromValue( g_UserUnit, value, Internal_Unit, true ); + msg = ReturnStringFromValue( g_UserUnit, value, true ); } else msg = _( "Default" ); m_gridDisplayCurrentSettings->SetCellValue( 1, 1, msg ); value = netclass->GetViaDrill(); // Display via drill - msg = ReturnStringFromValue( g_UserUnit, value, Internal_Unit, true ); + msg = ReturnStringFromValue( g_UserUnit, value, true ); m_gridDisplayCurrentSettings->SetCellValue( 0, 2, msg ); value = board->GetCurrentViaDrill(); if( value >= 0 ) - msg = ReturnStringFromValue( g_UserUnit, value, Internal_Unit, true ); + msg = ReturnStringFromValue( g_UserUnit, value, true ); else msg = _( "Default" ); m_gridDisplayCurrentSettings->SetCellValue( 1, 2, msg ); value = netclass->GetuViaDiameter(); // Display micro via diameter - msg = ReturnStringFromValue( g_UserUnit, value, Internal_Unit, true ); + msg = ReturnStringFromValue( g_UserUnit, value, true ); m_gridDisplayCurrentSettings->SetCellValue( 0, 3, msg ); #if 0 // Currently we use always the default netclass value value = board->GetCurrentMicroViaSize(); - msg = ReturnStringFromValue( g_UserUnit, value, Internal_Unit, true ); + msg = ReturnStringFromValue( g_UserUnit, value, true ); #endif msg = _( "Default" ); m_gridDisplayCurrentSettings->SetCellValue( 1, 3, msg ); value = netclass->GetuViaDrill(); // Display micro via drill - msg = ReturnStringFromValue( g_UserUnit, value, Internal_Unit, true ); + msg = ReturnStringFromValue( g_UserUnit, value, true ); m_gridDisplayCurrentSettings->SetCellValue( 0, 4, msg ); #if 0 // Currently we use always the default netclass value value = board->GetCurrentMicroViaDrill(); if( value >= 0 ) - msg = ReturnStringFromValue( g_UserUnit, value, Internal_Unit, true ); + msg = ReturnStringFromValue( g_UserUnit, value, true ); else #endif msg = _( "Default" ); diff --git a/pcbnew/dialogs/dialog_graphic_item_properties.cpp b/pcbnew/dialogs/dialog_graphic_item_properties.cpp index 5da000436c..02d1e49331 100644 --- a/pcbnew/dialogs/dialog_graphic_item_properties.cpp +++ b/pcbnew/dialogs/dialog_graphic_item_properties.cpp @@ -18,6 +18,7 @@ #include #include #include +#include #include #include @@ -136,20 +137,15 @@ void DIALOG_GRAPHIC_ITEM_PROPERTIES::initDlg( ) break; } - PutValueInLocalUnits( *m_Center_StartXCtrl, m_Item->GetStart().x, - m_parent->GetInternalUnits() ); + PutValueInLocalUnits( *m_Center_StartXCtrl, m_Item->GetStart().x ); - PutValueInLocalUnits( *m_Center_StartYCtrl, m_Item->GetStart().y, - m_parent->GetInternalUnits() ); + PutValueInLocalUnits( *m_Center_StartYCtrl, m_Item->GetStart().y ); - PutValueInLocalUnits( *m_EndX_Radius_Ctrl, m_Item->GetEnd().x, - m_parent->GetInternalUnits() ); + PutValueInLocalUnits( *m_EndX_Radius_Ctrl, m_Item->GetEnd().x ); - PutValueInLocalUnits( *m_EndY_Ctrl, m_Item->GetEnd().y, - m_parent->GetInternalUnits() ); + PutValueInLocalUnits( *m_EndY_Ctrl, m_Item->GetEnd().y ); - PutValueInLocalUnits( *m_ThicknessCtrl, m_Item->GetWidth(), - m_parent->GetInternalUnits() ); + PutValueInLocalUnits( *m_ThicknessCtrl, m_Item->GetWidth() ); int thickness; @@ -158,8 +154,7 @@ void DIALOG_GRAPHIC_ITEM_PROPERTIES::initDlg( ) else thickness = m_brdSettings.m_DrawSegmentWidth; - PutValueInLocalUnits( *m_DefaultThicknessCtrl, thickness, - m_parent->GetInternalUnits() ); + PutValueInLocalUnits( *m_DefaultThicknessCtrl, thickness ); for( int layer=FIRST_NO_COPPER_LAYER; layer <= LAST_NO_COPPER_LAYER; ++layer ) { @@ -187,8 +182,7 @@ void DIALOG_GRAPHIC_ITEM_PROPERTIES::OnLayerChoice( wxCommandEvent& event ) else thickness = m_brdSettings.m_DrawSegmentWidth; - PutValueInLocalUnits( *m_DefaultThicknessCtrl, thickness, - m_parent->GetInternalUnits() ); + PutValueInLocalUnits( *m_DefaultThicknessCtrl, thickness ); } /*******************************************************************/ diff --git a/pcbnew/dialogs/dialog_graphic_item_properties_for_Modedit.cpp b/pcbnew/dialogs/dialog_graphic_item_properties_for_Modedit.cpp index fac6f67cd4..1d4da8117e 100644 --- a/pcbnew/dialogs/dialog_graphic_item_properties_for_Modedit.cpp +++ b/pcbnew/dialogs/dialog_graphic_item_properties_for_Modedit.cpp @@ -17,6 +17,7 @@ #include #include #include +#include #include #include @@ -138,23 +139,17 @@ void DIALOG_MODEDIT_FP_BODY_ITEM_PROPERTIES::initDlg() break; } - PutValueInLocalUnits( *m_Center_StartXCtrl, m_item->GetStart().x, - m_parent->GetInternalUnits() ); + PutValueInLocalUnits( *m_Center_StartXCtrl, m_item->GetStart().x ); - PutValueInLocalUnits( *m_Center_StartYCtrl, m_item->GetStart().y, - m_parent->GetInternalUnits() ); + PutValueInLocalUnits( *m_Center_StartYCtrl, m_item->GetStart().y ); - PutValueInLocalUnits( *m_EndX_Radius_Ctrl, m_item->GetEnd().x, - m_parent->GetInternalUnits() ); + PutValueInLocalUnits( *m_EndX_Radius_Ctrl, m_item->GetEnd().x ); - PutValueInLocalUnits( *m_EndY_Ctrl, m_item->GetEnd().y, - m_parent->GetInternalUnits() ); + PutValueInLocalUnits( *m_EndY_Ctrl, m_item->GetEnd().y ); - PutValueInLocalUnits( *m_ThicknessCtrl, m_item->GetWidth(), - m_parent->GetInternalUnits() ); + PutValueInLocalUnits( *m_ThicknessCtrl, m_item->GetWidth() ); - PutValueInLocalUnits( *m_DefaultThicknessCtrl, m_brdSettings.m_ModuleSegmentWidth, - m_parent->GetInternalUnits() ); + PutValueInLocalUnits( *m_DefaultThicknessCtrl, m_brdSettings.m_ModuleSegmentWidth ); m_LayerSelectionCtrl->Append( m_parent->GetBoard()->GetLayerName( LAYER_N_BACK ) ); m_layerId.push_back( LAYER_N_BACK ); diff --git a/pcbnew/dialogs/dialog_graphic_items_options.cpp b/pcbnew/dialogs/dialog_graphic_items_options.cpp index 2d383390f4..2e364439b0 100644 --- a/pcbnew/dialogs/dialog_graphic_items_options.cpp +++ b/pcbnew/dialogs/dialog_graphic_items_options.cpp @@ -7,6 +7,7 @@ #include #include +#include #include #include @@ -58,50 +59,39 @@ void DIALOG_GRAPHIC_ITEMS_OPTIONS::initValues() /* Drawings width */ AddUnitSymbol( *m_GraphicSegmWidthTitle ); - PutValueInLocalUnits( *m_OptPcbSegmWidth, - m_brdSettings.m_DrawSegmentWidth, - PCB_INTERNAL_UNIT ); + PutValueInLocalUnits( *m_OptPcbSegmWidth, m_brdSettings.m_DrawSegmentWidth ); + /* Edges width */ AddUnitSymbol( *m_BoardEdgesWidthTitle ); - PutValueInLocalUnits( *m_OptPcbEdgesWidth, - m_brdSettings.m_EdgeSegmentWidth, - PCB_INTERNAL_UNIT ); + PutValueInLocalUnits( *m_OptPcbEdgesWidth, m_brdSettings.m_EdgeSegmentWidth ); /* Pcb Textes (Size & Width) */ AddUnitSymbol( *m_CopperTextWidthTitle ); - PutValueInLocalUnits( *m_OptPcbTextWidth, - m_brdSettings.m_PcbTextWidth, PCB_INTERNAL_UNIT ); + PutValueInLocalUnits( *m_OptPcbTextWidth, m_brdSettings.m_PcbTextWidth ); AddUnitSymbol( *m_TextSizeVTitle ); - PutValueInLocalUnits( *m_OptPcbTextVSize, - m_brdSettings.m_PcbTextSize.y, PCB_INTERNAL_UNIT ); + PutValueInLocalUnits( *m_OptPcbTextVSize, m_brdSettings.m_PcbTextSize.y ); AddUnitSymbol( *m_TextSizeHTitle ); - PutValueInLocalUnits( *m_OptPcbTextHSize, - m_brdSettings.m_PcbTextSize.x, PCB_INTERNAL_UNIT ); + PutValueInLocalUnits( *m_OptPcbTextHSize, m_brdSettings.m_PcbTextSize.x ); /* Modules: Edges width */ AddUnitSymbol( *m_EdgeModWidthTitle ); - PutValueInLocalUnits( *m_OptModuleEdgesWidth, - m_brdSettings.m_ModuleSegmentWidth, PCB_INTERNAL_UNIT ); + PutValueInLocalUnits( *m_OptModuleEdgesWidth, m_brdSettings.m_ModuleSegmentWidth ); /* Modules: Texts: Size & width */ AddUnitSymbol( *m_TextModWidthTitle ); - PutValueInLocalUnits( *m_OptModuleTextWidth, - m_brdSettings.m_ModuleTextWidth, PCB_INTERNAL_UNIT ); + PutValueInLocalUnits( *m_OptModuleTextWidth, m_brdSettings.m_ModuleTextWidth ); AddUnitSymbol( *m_TextModSizeVTitle ); - PutValueInLocalUnits( *m_OptModuleTextVSize, - m_brdSettings.m_ModuleTextSize.y, PCB_INTERNAL_UNIT ); + PutValueInLocalUnits( *m_OptModuleTextVSize, m_brdSettings.m_ModuleTextSize.y ); AddUnitSymbol( *m_TextModSizeHTitle ); - PutValueInLocalUnits( *m_OptModuleTextHSize, - m_brdSettings.m_ModuleTextSize.x, PCB_INTERNAL_UNIT ); + PutValueInLocalUnits( *m_OptModuleTextHSize, m_brdSettings.m_ModuleTextSize.x ); AddUnitSymbol( *m_DefaultPenSizeTitle ); - PutValueInLocalUnits( *m_DefaultPenSizeCtrl, - g_DrawDefaultLineThickness, PCB_INTERNAL_UNIT ); + PutValueInLocalUnits( *m_DefaultPenSizeCtrl, g_DrawDefaultLineThickness ); } diff --git a/pcbnew/dialogs/dialog_mask_clearance.cpp b/pcbnew/dialogs/dialog_mask_clearance.cpp index 126fbe79f1..eb862c6451 100644 --- a/pcbnew/dialogs/dialog_mask_clearance.cpp +++ b/pcbnew/dialogs/dialog_mask_clearance.cpp @@ -28,6 +28,7 @@ #include #include #include +#include #include @@ -59,16 +60,11 @@ void DIALOG_PADS_MASK_CLEARANCE::MyInit() m_SolderMaskMarginUnits->SetLabel( GetUnitsLabel( g_UserUnit ) ); m_SolderPasteMarginUnits->SetLabel( GetUnitsLabel( g_UserUnit ) ); - int Internal_Unit = m_Parent->GetInternalUnits(); - PutValueInLocalUnits( *m_SolderMaskMarginCtrl, - m_BrdSettings.m_SolderMaskMargin, - Internal_Unit ); + PutValueInLocalUnits( *m_SolderMaskMarginCtrl, m_BrdSettings.m_SolderMaskMargin ); // These 2 parameters are usually < 0, so prepare entering a negative // value, if current is 0 - PutValueInLocalUnits( *m_SolderPasteMarginCtrl, - m_BrdSettings.m_SolderPasteMargin, - Internal_Unit ); + PutValueInLocalUnits( *m_SolderPasteMarginCtrl, m_BrdSettings.m_SolderPasteMargin ); if( m_BrdSettings.m_SolderPasteMargin == 0 ) m_SolderPasteMarginCtrl->SetValue( wxT( "-" ) + diff --git a/pcbnew/dialogs/dialog_pad_properties.cpp b/pcbnew/dialogs/dialog_pad_properties.cpp index b9f4a76861..18f7175157 100644 --- a/pcbnew/dialogs/dialog_pad_properties.cpp +++ b/pcbnew/dialogs/dialog_pad_properties.cpp @@ -37,6 +37,7 @@ #include #include #include +#include #include #include @@ -243,7 +244,6 @@ void PCB_BASE_FRAME::InstallPadOptionsFrame( D_PAD* aPad ) void DIALOG_PAD_PROPERTIES::initValues() { - int internalUnits = m_Parent->GetInternalUnits(); wxString msg; double angle; @@ -319,42 +319,38 @@ void DIALOG_PAD_PROPERTIES::initValues() m_ThermalGapUnits->SetLabel( GetUnitsLabel( g_UserUnit ) ); // Display current pad parameters units: - PutValueInLocalUnits( *m_PadPosition_X_Ctrl, m_dummyPad->GetPosition().x, internalUnits ); - PutValueInLocalUnits( *m_PadPosition_Y_Ctrl, m_dummyPad->GetPosition().y, internalUnits ); + PutValueInLocalUnits( *m_PadPosition_X_Ctrl, m_dummyPad->GetPosition().x ); + PutValueInLocalUnits( *m_PadPosition_Y_Ctrl, m_dummyPad->GetPosition().y ); - PutValueInLocalUnits( *m_PadDrill_X_Ctrl, m_dummyPad->GetDrillSize().x, internalUnits ); - PutValueInLocalUnits( *m_PadDrill_Y_Ctrl, m_dummyPad->GetDrillSize().y, internalUnits ); + PutValueInLocalUnits( *m_PadDrill_X_Ctrl, m_dummyPad->GetDrillSize().x ); + PutValueInLocalUnits( *m_PadDrill_Y_Ctrl, m_dummyPad->GetDrillSize().y ); - PutValueInLocalUnits( *m_ShapeSize_X_Ctrl, m_dummyPad->GetSize().x, internalUnits ); - PutValueInLocalUnits( *m_ShapeSize_Y_Ctrl, m_dummyPad->GetSize().y, internalUnits ); + PutValueInLocalUnits( *m_ShapeSize_X_Ctrl, m_dummyPad->GetSize().x ); + PutValueInLocalUnits( *m_ShapeSize_Y_Ctrl, m_dummyPad->GetSize().y ); - PutValueInLocalUnits( *m_ShapeOffset_X_Ctrl, m_dummyPad->GetOffset().x, internalUnits ); - PutValueInLocalUnits( *m_ShapeOffset_Y_Ctrl, m_dummyPad->GetOffset().y, internalUnits ); + PutValueInLocalUnits( *m_ShapeOffset_X_Ctrl, m_dummyPad->GetOffset().x ); + PutValueInLocalUnits( *m_ShapeOffset_Y_Ctrl, m_dummyPad->GetOffset().y ); if( m_dummyPad->GetDelta().x ) { - PutValueInLocalUnits( *m_ShapeDelta_Ctrl, m_dummyPad->GetDelta().x, internalUnits ); + PutValueInLocalUnits( *m_ShapeDelta_Ctrl, m_dummyPad->GetDelta().x ); m_trapDeltaDirChoice->SetSelection( 0 ); } else { - PutValueInLocalUnits( *m_ShapeDelta_Ctrl, m_dummyPad->GetDelta().y, internalUnits ); + PutValueInLocalUnits( *m_ShapeDelta_Ctrl, m_dummyPad->GetDelta().y ); m_trapDeltaDirChoice->SetSelection( 1 ); } - PutValueInLocalUnits( *m_LengthDieCtrl, m_dummyPad->GetDieLength(), internalUnits ); + PutValueInLocalUnits( *m_LengthDieCtrl, m_dummyPad->GetDieLength() ); - PutValueInLocalUnits( *m_NetClearanceValueCtrl, m_dummyPad->GetLocalClearance(), internalUnits ); - PutValueInLocalUnits( *m_SolderMaskMarginCtrl, - m_dummyPad->GetLocalSolderMaskMargin(), - internalUnits ); - PutValueInLocalUnits( *m_ThermalWidthCtrl, m_dummyPad->GetThermalWidth(), internalUnits ); - PutValueInLocalUnits( *m_ThermalGapCtrl, m_dummyPad->GetThermalGap(), internalUnits ); + PutValueInLocalUnits( *m_NetClearanceValueCtrl, m_dummyPad->GetLocalClearance() ); + PutValueInLocalUnits( *m_SolderMaskMarginCtrl, m_dummyPad->GetLocalSolderMaskMargin() ); + PutValueInLocalUnits( *m_ThermalWidthCtrl, m_dummyPad->GetThermalWidth() ); + PutValueInLocalUnits( *m_ThermalGapCtrl, m_dummyPad->GetThermalGap() ); // These 2 parameters are usually < 0, so prepare entering a negative value, if current is 0 - PutValueInLocalUnits( *m_SolderPasteMarginCtrl, - m_dummyPad->GetLocalSolderPasteMargin(), - internalUnits ); + PutValueInLocalUnits( *m_SolderPasteMarginCtrl, m_dummyPad->GetLocalSolderPasteMargin() ); if( m_dummyPad->GetLocalSolderPasteMargin() == 0 ) m_SolderPasteMarginCtrl->SetValue( wxT( "-" ) + m_SolderPasteMarginCtrl->GetValue() ); diff --git a/pcbnew/dialogs/dialog_pcb_text_properties.cpp b/pcbnew/dialogs/dialog_pcb_text_properties.cpp index 5b0e07d4c4..36cd766ef8 100644 --- a/pcbnew/dialogs/dialog_pcb_text_properties.cpp +++ b/pcbnew/dialogs/dialog_pcb_text_properties.cpp @@ -33,6 +33,7 @@ #include #include #include +#include #include #include @@ -113,16 +114,11 @@ void DIALOG_PCB_TEXT_PROPERTIES::MyInit() // Fill fields with current values *m_TextContentCtrl << m_SelectedPCBText->m_Text; - PutValueInLocalUnits( *m_SizeXCtrl, m_SelectedPCBText->m_Size.x, - m_Parent->GetInternalUnits() ); - PutValueInLocalUnits( *m_SizeYCtrl, m_SelectedPCBText->m_Size.y, - m_Parent->GetInternalUnits() ); - PutValueInLocalUnits( *m_ThicknessCtrl, m_SelectedPCBText->m_Thickness, - m_Parent->GetInternalUnits() ); - PutValueInLocalUnits( *m_PositionXCtrl, m_SelectedPCBText->m_Pos.x, - m_Parent->GetInternalUnits() ); - PutValueInLocalUnits( *m_PositionYCtrl, m_SelectedPCBText->m_Pos.y, - m_Parent->GetInternalUnits() ); + PutValueInLocalUnits( *m_SizeXCtrl, m_SelectedPCBText->m_Size.x ); + PutValueInLocalUnits( *m_SizeYCtrl, m_SelectedPCBText->m_Size.y ); + PutValueInLocalUnits( *m_ThicknessCtrl, m_SelectedPCBText->m_Thickness ); + PutValueInLocalUnits( *m_PositionXCtrl, m_SelectedPCBText->m_Pos.x ); + PutValueInLocalUnits( *m_PositionYCtrl, m_SelectedPCBText->m_Pos.y ); int enabledLayers = m_Parent->GetBoard()->GetEnabledLayers(); diff --git a/pcbnew/dialogs/dialog_print_using_printer.cpp b/pcbnew/dialogs/dialog_print_using_printer.cpp index 095ef993c0..2824582bd0 100644 --- a/pcbnew/dialogs/dialog_print_using_printer.cpp +++ b/pcbnew/dialogs/dialog_print_using_printer.cpp @@ -10,6 +10,7 @@ #include #include #include +#include #include #include @@ -260,7 +261,7 @@ void DIALOG_PRINT_USING_PRINTER::InitValues( ) s_Parameters.m_PenDefaultSize = g_DrawDefaultLineThickness; AddUnitSymbol( *m_TextPenWidth, g_UserUnit ); m_DialogPenWidth->SetValue( - ReturnStringFromValue( g_UserUnit, s_Parameters.m_PenDefaultSize, m_parent->GetInternalUnits() ) ); + ReturnStringFromValue( g_UserUnit, s_Parameters.m_PenDefaultSize ) ); // Create scale adjust option msg.Printf( wxT( "%f" ), s_Parameters.m_XScaleAdjust ); @@ -399,7 +400,7 @@ void DIALOG_PRINT_USING_PRINTER::SetPenWidth() g_DrawDefaultLineThickness = s_Parameters.m_PenDefaultSize; m_DialogPenWidth->SetValue( - ReturnStringFromValue( g_UserUnit, s_Parameters.m_PenDefaultSize, m_parent->GetInternalUnits() ) ); + ReturnStringFromValue( g_UserUnit, s_Parameters.m_PenDefaultSize ) ); } void DIALOG_PRINT_USING_PRINTER::OnScaleSelectionClick( wxCommandEvent& event ) @@ -416,7 +417,7 @@ void DIALOG_PRINT_USING_PRINTER::OnScaleSelectionClick( wxCommandEvent& event ) void DIALOG_PRINT_USING_PRINTER::OnPageSetup( wxCommandEvent& event ) { - wxPageSetupDialog pageSetupDialog(this, s_pageSetupData); + wxPageSetupDialog pageSetupDialog( this, s_pageSetupData ); pageSetupDialog.ShowModal(); (*s_PrintData) = pageSetupDialog.GetPageSetupDialogData().GetPrintData(); diff --git a/pcbnew/dimension.cpp b/pcbnew/dimension.cpp index 07dd09c1bb..235a7a4314 100644 --- a/pcbnew/dimension.cpp +++ b/pcbnew/dimension.cpp @@ -11,6 +11,7 @@ #include #include #include +#include #include #include @@ -91,24 +92,19 @@ DIALOG_DIMENSION_EDITOR::DIALOG_DIMENSION_EDITOR( PCB_EDIT_FRAME* aParent, m_Name->SetValue( aDimension->m_Text.m_Text ); // Enter size value in dialog - PutValueInLocalUnits( *m_TxtSizeXCtrl, aDimension->m_Text.m_Size.x, - m_Parent->GetInternalUnits() ); + PutValueInLocalUnits( *m_TxtSizeXCtrl, aDimension->m_Text.m_Size.x ); AddUnitSymbol( *m_staticTextSizeX ); - PutValueInLocalUnits( *m_TxtSizeYCtrl, aDimension->m_Text.m_Size.y, - m_Parent->GetInternalUnits() ); + PutValueInLocalUnits( *m_TxtSizeYCtrl, aDimension->m_Text.m_Size.y ); AddUnitSymbol( *m_staticTextSizeY ); // Enter lines thickness value in dialog - PutValueInLocalUnits( *m_TxtWidthCtrl, aDimension->m_Width, - m_Parent->GetInternalUnits() ); + PutValueInLocalUnits( *m_TxtWidthCtrl, aDimension->m_Width ); AddUnitSymbol( *m_staticTextWidth ); // Enter position value in dialog - PutValueInLocalUnits( *m_textCtrlPosX, aDimension->m_Text.m_Pos.x, - m_Parent->GetInternalUnits() ); + PutValueInLocalUnits( *m_textCtrlPosX, aDimension->m_Text.m_Pos.x ); AddUnitSymbol( *m_staticTextPosX ); - PutValueInLocalUnits( *m_textCtrlPosY, aDimension->m_Text.m_Pos.y, - m_Parent->GetInternalUnits() ); + PutValueInLocalUnits( *m_textCtrlPosY, aDimension->m_Text.m_Pos.y ); AddUnitSymbol( *m_staticTextPosY ); for( int layer = FIRST_NO_COPPER_LAYER; layer #include #include +#include #include #include @@ -55,14 +56,11 @@ void DRC::ShowDialog() // copy data retained in this DRC object into the m_ui DrcPanel: PutValueInLocalUnits( *m_ui->m_SetTrackMinWidthCtrl, - m_pcb->GetDesignSettings().m_TrackMinWidth, - m_mainWindow->GetInternalUnits() ); + m_pcb->GetDesignSettings().m_TrackMinWidth ); PutValueInLocalUnits( *m_ui->m_SetViaMinSizeCtrl, - m_pcb->GetDesignSettings().m_ViasMinSize, - m_mainWindow->GetInternalUnits() ); + m_pcb->GetDesignSettings().m_ViasMinSize ); PutValueInLocalUnits( *m_ui->m_SetMicroViakMinSizeCtrl, - m_pcb->GetDesignSettings().m_MicroViasMinSize, - m_mainWindow->GetInternalUnits() ); + m_pcb->GetDesignSettings().m_MicroViasMinSize ); m_ui->m_CreateRptCtrl->SetValue( m_doCreateRptFile ); m_ui->m_RptFilenameCtrl->SetValue( m_rptFilename ); @@ -294,7 +292,7 @@ bool DRC::doNetClass( NETCLASS* nc, wxString& msg ) const BOARD_DESIGN_SETTINGS& g = m_pcb->GetDesignSettings(); -#define FmtVal( x ) GetChars( ReturnStringFromValue( g_UserUnit, x, PCB_INTERNAL_UNIT ) ) +#define FmtVal( x ) GetChars( ReturnStringFromValue( g_UserUnit, x ) ) #if 0 // set to 1 when (if...) BOARD_DESIGN_SETTINGS has a m_MinClearance value if( nc->GetClearance() < g.m_MinClearance ) diff --git a/pcbnew/edgemod.cpp b/pcbnew/edgemod.cpp index ac1023086b..d755ab1a50 100644 --- a/pcbnew/edgemod.cpp +++ b/pcbnew/edgemod.cpp @@ -36,6 +36,7 @@ #include #include #include +#include #include #include @@ -238,8 +239,7 @@ void FOOTPRINT_EDIT_FRAME::Enter_Edge_Width( EDGE_MODULE* aEdge ) { wxString buffer; - buffer = ReturnStringFromValue( g_UserUnit, GetDesignSettings().m_ModuleSegmentWidth, - GetScreen()->GetInternalUnits() ); + buffer = ReturnStringFromValue( g_UserUnit, GetDesignSettings().m_ModuleSegmentWidth ); wxTextEntryDialog dlg( this, _( "New Width:" ), _( "Edge Width" ), buffer ); if( dlg.ShowModal() != wxID_OK ) diff --git a/pcbnew/muonde.cpp b/pcbnew/muonde.cpp index c82558dc0e..ac8e31da57 100644 --- a/pcbnew/muonde.cpp +++ b/pcbnew/muonde.cpp @@ -41,6 +41,7 @@ #include #include #include +#include #include #include @@ -197,7 +198,7 @@ MODULE* PCB_EDIT_FRAME::Genere_Self( wxDC* DC ) Mself.lng = min_len; // Enter the desired length. - msg = ReturnStringFromValue( g_UserUnit, Mself.lng, GetScreen()->GetInternalUnits() ); + msg = ReturnStringFromValue( g_UserUnit, Mself.lng ); wxTextEntryDialog dlg( this, _( "Length:" ), _( "Length" ), msg ); if( dlg.ShowModal() != wxID_OK ) @@ -610,8 +611,7 @@ MODULE* PCB_EDIT_FRAME::Create_MuWaveComponent( int shape_type ) break; } - wxString value = ReturnStringFromValue( g_UserUnit, gap_size, - GetScreen()->GetInternalUnits() ); + wxString value = ReturnStringFromValue( g_UserUnit, gap_size ); wxTextEntryDialog dlg( this, msg, _( "Create microwave module" ), value ); if( dlg.ShowModal() != wxID_OK ) @@ -1087,7 +1087,7 @@ void PCB_EDIT_FRAME::Edit_Gap( wxDC* DC, MODULE* aModule ) gap_size = next_pad->GetPos0().x - pad->GetPos0().x - pad->GetSize().x; // Entrer the desired length of the gap. - msg = ReturnStringFromValue( g_UserUnit, gap_size, GetScreen()->GetInternalUnits() ); + msg = ReturnStringFromValue( g_UserUnit, gap_size ); wxTextEntryDialog dlg( this, _( "Gap:" ), _( "Create Microwave Gap" ), msg ); if( dlg.ShowModal() != wxID_OK ) diff --git a/pcbnew/onrightclick.cpp b/pcbnew/onrightclick.cpp index b61dbf25bb..cc3f769e0d 100644 --- a/pcbnew/onrightclick.cpp +++ b/pcbnew/onrightclick.cpp @@ -31,6 +31,7 @@ #include #include #include +#include #include #include @@ -888,8 +889,7 @@ static wxMenu* Append_Track_Width_List( BOARD* aBoard ) for( unsigned ii = 0; ii < aBoard->m_TrackWidthList.size(); ii++ ) { - value = ReturnStringFromValue( g_UserUnit, aBoard->m_TrackWidthList[ii], - PCB_INTERNAL_UNIT, true ); + value = ReturnStringFromValue( g_UserUnit, aBoard->m_TrackWidthList[ii], true ); msg.Printf( _( "Track %s" ), GetChars( value ) ); if( ii == 0 ) @@ -903,10 +903,10 @@ static wxMenu* Append_Track_Width_List( BOARD* aBoard ) for( unsigned ii = 0; ii < aBoard->m_ViasDimensionsList.size(); ii++ ) { value = ReturnStringFromValue( g_UserUnit, aBoard->m_ViasDimensionsList[ii].m_Diameter, - PCB_INTERNAL_UNIT, true ); + true ); wxString drill = ReturnStringFromValue( g_UserUnit, aBoard->m_ViasDimensionsList[ii].m_Drill, - PCB_INTERNAL_UNIT, true ); + true ); if( aBoard->m_ViasDimensionsList[ii].m_Drill <= 0 ) { diff --git a/pcbnew/pcbplot.cpp b/pcbnew/pcbplot.cpp index 827c7fe5f3..da074ec1e2 100644 --- a/pcbnew/pcbplot.cpp +++ b/pcbnew/pcbplot.cpp @@ -12,6 +12,7 @@ #include #include #include +#include #include @@ -120,21 +121,20 @@ void DIALOG_PLOT::Init_Dialog() // Set units and value for HPGL pen size. AddUnitSymbol( *m_textPenSize, g_UserUnit ); - msg = ReturnStringFromValue( g_UserUnit, m_plotOpts.GetHpglPenDiameter(), UNITS_MILS ); + msg = ReturnStringFromValue( g_UserUnit, m_plotOpts.GetHpglPenDiameter() * 10 ); m_HPGLPenSizeOpt->AppendText( msg ); // Set units to cm/s for standard HPGL pen speed. - msg = ReturnStringFromValue( UNSCALED_UNITS, m_plotOpts.GetHpglPenSpeed(), 1 ); + msg = ReturnStringFromValue( UNSCALED_UNITS, m_plotOpts.GetHpglPenSpeed() * 10000 ); m_HPGLPenSpeedOpt->AppendText( msg ); // Set units and value for HPGL pen overlay. AddUnitSymbol( *m_textPenOvr, g_UserUnit ); - msg = ReturnStringFromValue( g_UserUnit, m_plotOpts.GetHpglPenOverlay(), UNITS_MILS ); + msg = ReturnStringFromValue( g_UserUnit, m_plotOpts.GetHpglPenOverlay() * 10 ); m_HPGLPenOverlayOpt->AppendText( msg ); AddUnitSymbol( *m_textDefaultPenSize, g_UserUnit ); - msg = ReturnStringFromValue( g_UserUnit, m_plotOpts.GetPlotLineWidth(), - PCB_INTERNAL_UNIT ); + msg = ReturnStringFromValue( g_UserUnit, m_plotOpts.GetPlotLineWidth() ); m_linesWidth->AppendText( msg ); // Set units for PS global width correction. @@ -157,7 +157,7 @@ void DIALOG_PLOT::Init_Dialog() if( m_PSWidthAdjust < m_WidthAdjustMinValue || m_PSWidthAdjust > m_WidthAdjustMaxValue ) m_PSWidthAdjust = 0.; - msg.Printf( wxT( "%f" ), To_User_Unit( g_UserUnit, m_PSWidthAdjust, PCB_INTERNAL_UNIT ) ); + msg.Printf( wxT( "%f" ), To_User_Unit( g_UserUnit, m_PSWidthAdjust ) ); m_PSFineAdjustWidthOpt->AppendText( msg ); m_plotPSNegativeOpt->SetValue( m_plotOpts.m_PlotPSNegative ); @@ -454,7 +454,7 @@ void DIALOG_PLOT::applyPlotSettings() if( !tempOptions.SetHpglPenDiameter( tmp ) ) { - msg = ReturnStringFromValue( g_UserUnit, tempOptions.GetHpglPenDiameter(), UNITS_MILS ); + msg = ReturnStringFromValue( g_UserUnit, tempOptions.GetHpglPenDiameter() * 10 ); m_HPGLPenSizeOpt->SetValue( msg ); msg.Printf( _( "HPGL pen size constrained!\n" ) ); m_messagesBox->AppendText( msg ); @@ -466,7 +466,7 @@ void DIALOG_PLOT::applyPlotSettings() if( !tempOptions.SetHpglPenSpeed( tmp ) ) { - msg = ReturnStringFromValue( UNSCALED_UNITS, tempOptions.GetHpglPenSpeed(), 1 ); + msg = ReturnStringFromValue( UNSCALED_UNITS, tempOptions.GetHpglPenSpeed() * 1000 ); m_HPGLPenSpeedOpt->SetValue( msg ); msg.Printf( _( "HPGL pen speed constrained!\n" ) ); m_messagesBox->AppendText( msg ); @@ -478,7 +478,7 @@ void DIALOG_PLOT::applyPlotSettings() if( !tempOptions.SetHpglPenOverlay( tmp ) ) { - msg = ReturnStringFromValue( g_UserUnit, tempOptions.GetHpglPenOverlay(), UNITS_MILS ); + msg = ReturnStringFromValue( g_UserUnit, tempOptions.GetHpglPenOverlay() * 10 ); m_HPGLPenOverlayOpt->SetValue( msg ); msg.Printf( _( "HPGL pen overlay constrained!\n" ) ); m_messagesBox->AppendText( msg ); @@ -490,8 +490,7 @@ void DIALOG_PLOT::applyPlotSettings() if( !tempOptions.SetPlotLineWidth( tmp ) ) { - msg = ReturnStringFromValue( g_UserUnit, tempOptions.GetPlotLineWidth(), - PCB_INTERNAL_UNIT ); + msg = ReturnStringFromValue( g_UserUnit, tempOptions.GetPlotLineWidth() ); m_linesWidth->SetValue( msg ); msg.Printf( _( "Default linewidth constrained!\n" ) ); m_messagesBox->AppendText( msg ); @@ -532,13 +531,13 @@ void DIALOG_PLOT::applyPlotSettings() if( !setDouble( &m_PSWidthAdjust, tmpDouble, m_WidthAdjustMinValue, m_WidthAdjustMaxValue ) ) { - msg = ReturnStringFromValue( g_UserUnit, m_PSWidthAdjust, PCB_INTERNAL_UNIT ); + msg = ReturnStringFromValue( g_UserUnit, m_PSWidthAdjust ); m_PSFineAdjustWidthOpt->SetValue( msg ); msg.Printf( _( "Width correction constrained!\n" "The reasonable width correction value must be in a range of\n" " [%+f; %+f] (%s) for current design rules!\n" ), - To_User_Unit( g_UserUnit, m_WidthAdjustMinValue, PCB_INTERNAL_UNIT ), - To_User_Unit( g_UserUnit, m_WidthAdjustMaxValue, PCB_INTERNAL_UNIT ), + To_User_Unit( g_UserUnit, m_WidthAdjustMinValue ), + To_User_Unit( g_UserUnit, m_WidthAdjustMaxValue ), ( g_UserUnit == INCHES )? wxT("\"") : wxT("mm") ); m_messagesBox->AppendText( msg ); } @@ -610,7 +609,7 @@ void DIALOG_PLOT::Plot( wxCommandEvent& event ) else { wxMessageBox( _( "Cannot create output directory!" ), - _( "Plot" ), wxOK | wxICON_ERROR ); + _( "Plot" ), wxOK | wxICON_ERROR ); return; } } diff --git a/pcbnew/set_grid.cpp b/pcbnew/set_grid.cpp index c49fc46a06..a551eaef2f 100644 --- a/pcbnew/set_grid.cpp +++ b/pcbnew/set_grid.cpp @@ -7,6 +7,7 @@ #include #include #include +#include #include #include @@ -135,8 +136,8 @@ void DIALOG_SET_GRID::SetGridOrigin( const wxPoint& grid ) { wxString msg; - PutValueInLocalUnits( *m_GridOriginXCtrl, grid.x, m_internalUnits ); - PutValueInLocalUnits( *m_GridOriginYCtrl, grid.y, m_internalUnits ); + PutValueInLocalUnits( *m_GridOriginXCtrl, grid.x ); + PutValueInLocalUnits( *m_GridOriginYCtrl, grid.y ); } void DIALOG_SET_GRID::SetGridForFastSwitching( wxArrayString aGrids, int aGrid1, int aGrid2 ) diff --git a/pcbnew/zones_non_copper_type_functions.cpp b/pcbnew/zones_non_copper_type_functions.cpp index fee5d30791..310343373c 100644 --- a/pcbnew/zones_non_copper_type_functions.cpp +++ b/pcbnew/zones_non_copper_type_functions.cpp @@ -6,6 +6,7 @@ #include #include #include +#include #include #include @@ -79,9 +80,7 @@ void DIALOG_NON_COPPER_ZONES_EDITOR::Init() m_FillModeCtrl->SetSelection( m_settings.m_FillMode ? 1 : 0 ); AddUnitSymbol( *m_MinThicknessValueTitle, g_UserUnit ); - wxString msg = ReturnStringFromValue( g_UserUnit, - m_settings.m_ZoneMinThickness, - m_Parent->GetInternalUnits() ); + wxString msg = ReturnStringFromValue( g_UserUnit, m_settings.m_ZoneMinThickness ); m_ZoneMinThicknessCtrl->SetValue( msg ); if( m_settings.m_Zone_45_Only )