Commit 57d75a75 authored by Wayne Stambaugh's avatar Wayne Stambaugh

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.
parent b28e976e
......@@ -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
......
/*
* 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 <stambaughw@verizon.net>
* @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 <base_struct.h>
#include <class_title_block.h>
#include <common.h>
#include <base_units.h>
#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 );
}
......@@ -36,6 +36,8 @@
#include <macros.h>
#include <build_version.h>
#include <confirm.h>
#include <base_units.h>
#include <wx/process.h>
/**
......@@ -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,52 +450,36 @@ const wxString& valeur_param( int valeur, wxString& buf_texte )
}
wxString CoordinateToString( int aValue, int aInternalUnits, bool aConvertToMils )
wxString& operator <<( wxString& aString, const wxPoint& aPos )
{
wxCHECK_MSG( (aInternalUnits == EESCHEMA_INTERNAL_UNIT)
|| (aInternalUnits == PCB_INTERNAL_UNIT),
wxString( _( "*** Bad Internal Units ***" ) ),
wxT( "Invalid interanl units value." ) );
wxString temp;
wxString text;
const wxChar* format;
double value = To_User_Unit( g_UserUnit, aValue, aInternalUnits );
aString << wxT( "@ (" ) << valeur_param( aPos.x, temp );
aString << wxT( "," ) << valeur_param( aPos.y, temp );
aString << wxT( ")" );
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" );
}
return aString;
}
text.Printf( format, value );
if( g_UserUnit == INCHES )
text += ( aConvertToMils ) ? _( " mils" ) : _( " in" );
else
text += _( " mm" );
double RoundTo0( double x, double precision )
{
assert( precision != 0 );
return text;
}
long long ix = wxRound( x * precision );
if ( x < 0.0 )
NEGATE( ix );
wxString& operator <<( wxString& aString, const wxPoint& aPos )
{
wxString temp;
int remainder = ix % 10; // remainder is in precision mm
aString << wxT( "@ (" ) << valeur_param( aPos.x, temp );
aString << wxT( "," ) << valeur_param( aPos.y, temp );
aString << wxT( ")" );
if ( remainder <= 2 )
ix -= remainder; // truncate to the near number
else if (remainder >= 8 )
ix += 10 - remainder; // round to near number
return aString;
if ( x < 0 )
NEGATE( ix );
return (double) ix / precision;
}
......@@ -40,6 +40,7 @@
#include <confirm.h>
#include <kicad_device_context.h>
#include <dialog_helpers.h>
#include <base_units.h>
#include <wx/fontdlg.h>
......@@ -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 );
}
......
/*
* 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 <fctsys.h>
#include <wxstruct.h>
#include <dialog_helpers.h>
#include <base_units.h>
/*******************************************************/
......@@ -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 );
}
......
/************/
/* 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 <kicad_device_context.h>
#include <hotkeys_basic.h>
#include <menus_helpers.h>
#include <base_units.h>
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 )
{
......
......@@ -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
)
......
......@@ -36,6 +36,8 @@
#include <class_sch_screen.h>
#include <wxEeschemaStruct.h>
#include <dcsvg.h>
#include <base_units.h>
#include <general.h>
#include <libeditframe.h>
#include <sch_sheet_path.h>
......@@ -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 ) );
}
......
......@@ -11,6 +11,7 @@
#include <confirm.h>
#include <class_sch_screen.h>
#include <wxEeschemaStruct.h>
#include <base_units.h>
#include <general.h>
#include <class_library.h>
......@@ -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 );
}
......
......@@ -31,6 +31,7 @@
#include <fctsys.h>
#include <wx/valgen.h>
#include <wxEeschemaStruct.h>
#include <base_units.h>
#include <class_drawpanel.h>
#include <general.h>
......@@ -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
......
......@@ -10,6 +10,7 @@
#include <class_drawpanel.h>
#include <wxEeschemaStruct.h>
#include <id.h>
#include <base_units.h>
#include <general.h>
#include <protos.h>
......@@ -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 );
}
......
......@@ -29,6 +29,7 @@
#include <fctsys.h>
#include <common.h>
#include <base_units.h>
#include <general.h>
#include <sch_base_frame.h>
......@@ -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 )
......
......@@ -31,6 +31,7 @@
#include <gr_basic.h>
#include <common.h>
#include <class_drawpanel.h>
#include <base_units.h>
#include <general.h>
#include <libeditframe.h>
......@@ -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 )
......
......@@ -32,6 +32,7 @@
#include <worksheet.h>
#include <class_sch_screen.h>
#include <wxEeschemaStruct.h>
#include <base_units.h>
#include <general.h>
#include <protos.h>
......@@ -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 );
......
......@@ -32,6 +32,7 @@
#include <plot_common.h>
#include <class_sch_screen.h>
#include <wxEeschemaStruct.h>
#include <base_units.h>
#include <general.h>
#include <protos.h>
......@@ -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 );
}
......
......@@ -9,6 +9,7 @@
#include <confirm.h>
#include <class_sch_screen.h>
#include <wxEeschemaStruct.h>
#include <base_units.h>
#include <general.h>
#include <eeschema_config.h>
......
......@@ -40,6 +40,7 @@
#include <kicad_string.h>
#include <gestfich.h>
#include <wxEeschemaStruct.h>
#include <base_units.h>
#include <general.h>
#include <protos.h>
......@@ -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 );
......
......@@ -34,6 +34,7 @@
#include <trigo.h>
#include <wxstruct.h>
#include <richio.h>
#include <base_units.h>
#include <general.h>
#include <protos.h>
......@@ -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 ) ) );
}
......
......@@ -35,6 +35,7 @@
#include <wxstruct.h>
#include <bezier_curves.h>
#include <richio.h>
#include <base_units.h>
#include <general.h>
#include <protos.h>
......@@ -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 );
......
......@@ -35,6 +35,7 @@
#include <trigo.h>
#include <wxstruct.h>
#include <richio.h>
#include <base_units.h>
#include <general.h>
#include <protos.h>
......@@ -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 ) ) );
}
......
......@@ -36,6 +36,7 @@
#include <class_drawpanel.h>
#include <plot_common.h>
#include <trigo.h>
#include <base_units.h>
#include <general.h>
#include <protos.h>
......@@ -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 ...)
......
......@@ -36,6 +36,7 @@
#include <plot_common.h>
#include <wxEeschemaStruct.h>
#include <richio.h>
#include <base_units.h>
#include <general.h>
#include <protos.h>
......@@ -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 ) ] );
......
......@@ -34,6 +34,7 @@
#include <trigo.h>
#include <wxstruct.h>
#include <richio.h>
#include <base_units.h>
#include <general.h>
#include <protos.h>
......@@ -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() );
}
......
......@@ -34,6 +34,7 @@
#include <trigo.h>
#include <wxstruct.h>
#include <richio.h>
#include <base_units.h>
#include <general.h>
#include <protos.h>
......@@ -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 ) ) );
}
......
......@@ -35,6 +35,7 @@
#include <trigo.h>
#include <wxstruct.h>
#include <richio.h>
#include <base_units.h>
#include <lib_draw_item.h>
#include <general.h>
......@@ -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 );
}
......
......@@ -33,6 +33,7 @@
#include <class_drawpanel.h>
#include <confirm.h>
#include <class_sch_screen.h>
#include <base_units.h>
#include <libeditframe.h>
#include <eeschema_id.h>
......@@ -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 ) );
......
......@@ -25,6 +25,7 @@
#include <sch_base_frame.h>
#include <viewlib_frame.h>
#include <libeditframe.h>
#include <base_units.h>
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();
}
......@@ -34,6 +34,7 @@
#include <trigo.h>
#include <richio.h>
#include <plot_common.h>
#include <base_units.h>
#include <general.h>
#include <protos.h>
......@@ -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;
}
......
......@@ -31,6 +31,7 @@
#include <class_drawpanel.h>
#include <confirm.h>
#include <wxEeschemaStruct.h>
#include <base_units.h>
#include <general.h>
#include <sch_sheet.h>
......@@ -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
......
......@@ -34,6 +34,7 @@
#include <class_drawpanel.h>
#include <confirm.h>
#include <wxEeschemaStruct.h>
#include <base_units.h>
#include <general.h>
#include <protos.h>
......@@ -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() );
......
......@@ -33,6 +33,7 @@
#include <class_drawpanel.h>
#include <confirm.h>
#include <class_sch_screen.h>
#include <base_units.h>
#include <eeschema_id.h>
#include <general.h>
......@@ -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 );
......
/*
* 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 <stambaughw@verizon.net>
* @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 <common.h>
/**
* 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_
......@@ -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
*/
......
......@@ -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:
/**
......
......@@ -35,6 +35,7 @@
#include <dialog_helpers.h>
#include <kicad_device_context.h>
#include <wxBasePcbFrame.h>
#include <base_units.h>
#include <pcbnew.h>
#include <pcbnew_id.h>
......@@ -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();
if( DisplayOpt.DisplayPolarCood ) // display polar coordinates
{
PCB_SCREEN* screen = GetScreen();
PCB_SCREEN* screen = GetScreen();
if( !screen )
return;
if( !screen )
return;
int dx;
int dy;
double dXpos;
double dYpos;
wxString line;
wxString locformatter;
wxString Line;
if( DisplayOpt.DisplayPolarCood ) // display polar coordinates
{
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 )
{
......
......@@ -15,6 +15,7 @@
#include <wxBasePcbFrame.h>
#include <class_pcb_screen.h>
#include <macros.h>
#include <base_units.h>
#include <pcbnew.h>
#include <pcbplot.h>
......@@ -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 ) );
}
......
......@@ -15,6 +15,7 @@
#include <wxPcbStruct.h>
#include <trigo.h>
#include <zones.h>
#include <base_units.h>
#include <class_zone_settings.h>
#include <class_board.h>
......@@ -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 )
{
......
......@@ -33,6 +33,7 @@
#include <fctsys.h>
#include <class_drawpanel.h>
#include <macros.h>
#include <base_units.h>
#include <confirm.h>
#include <pcbnew.h>
......@@ -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( _( "<b>Current general settings:</b><br>" ) );
// 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: <b>%s</b><br>\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: <b>%s</b><br>\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: <b>%s</b><br>\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 );
}
......
......@@ -12,6 +12,7 @@
#include <3d_struct.h>
#include <3d_viewer.h>
#include <wxPcbStruct.h>
#include <base_units.h>
#include <class_module.h>
#include <class_text_mod.h>
......@@ -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() );
......
......@@ -11,6 +11,7 @@
#include <3d_struct.h>
#include <3d_viewer.h>
#include <wxPcbStruct.h>
#include <base_units.h>
#include <class_module.h>
#include <class_text_mod.h>
......@@ -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
......
......@@ -14,6 +14,7 @@
#include <drawtxt.h>
#include <confirm.h>
#include <wxBasePcbFrame.h>
#include <base_units.h>
#include <class_module.h>
#include <class_text_mod.h>
......@@ -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)
......
......@@ -10,6 +10,7 @@
#include <pcbnew.h>
#include <wxPcbStruct.h>
#include <class_drawpanel.h>
#include <base_units.h>
#include <class_board.h>
......@@ -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" );
......
......@@ -18,6 +18,7 @@
#include <pcbnew.h>
#include <wxPcbStruct.h>
#include <class_board_design_settings.h>
#include <base_units.h>
#include <class_board.h>
#include <class_drawsegment.h>
......@@ -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 );
}
/*******************************************************************/
......
......@@ -17,6 +17,7 @@
#include <wxPcbStruct.h>
#include <class_board_design_settings.h>
#include <module_editor_frame.h>
#include <base_units.h>
#include <class_board.h>
#include <class_module.h>
......@@ -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 );
......
......@@ -7,6 +7,7 @@
#include <pcbnew.h>
#include <wxPcbStruct.h>
#include <base_units.h>
#include <pcbnew_id.h>
#include <module_editor_frame.h>
......@@ -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 );
}
......
......@@ -28,6 +28,7 @@
#include <pcbnew.h>
#include <wxPcbStruct.h>
#include <class_board_design_settings.h>
#include <base_units.h>
#include <class_board.h>
......@@ -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( "-" ) +
......
......@@ -37,6 +37,7 @@
#include <macros.h>
#include <wxBasePcbFrame.h>
#include <pcbcommon.h>
#include <base_units.h>
#include <wx/dcbuffer.h>
#include <protos.h>
......@@ -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() );
......
......@@ -33,6 +33,7 @@
#include <wxPcbStruct.h>
#include <drawtxt.h>
#include <confirm.h>
#include <base_units.h>
#include <class_board.h>
#include <class_pcb_text.h>
......@@ -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();
......
......@@ -10,6 +10,7 @@
#include <class_drawpanel.h>
#include <confirm.h>
#include <wxPcbStruct.h>
#include <base_units.h>
#include <printout_controler.h>
#include <pcbnew.h>
......@@ -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();
......
......@@ -11,6 +11,7 @@
#include <drawtxt.h>
#include <dialog_helpers.h>
#include <macros.h>
#include <base_units.h>
#include <class_board.h>
#include <class_pcb_text.h>
......@@ -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<NB_LAYERS; layer++ )
......
......@@ -31,6 +31,7 @@
#include <fctsys.h>
#include <wxPcbStruct.h>
#include <trigo.h>
#include <base_units.h>
#include <class_board_design_settings.h>
#include <class_module.h>
......@@ -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 )
......
......@@ -36,6 +36,7 @@
#include <class_drawpanel.h>
#include <confirm.h>
#include <wxPcbStruct.h>
#include <base_units.h>
#include <module_editor_frame.h>
#include <class_board.h>
......@@ -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 )
......
......@@ -41,6 +41,7 @@
#include <gr_basic.h>
#include <pcbcommon.h>
#include <macros.h>
#include <base_units.h>
#include <class_board.h>
#include <class_module.h>
......@@ -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 )
......
......@@ -31,6 +31,7 @@
#include <fctsys.h>
#include <class_drawpanel.h>
#include <macros.h>
#include <base_units.h>
#include <class_board.h>
#include <class_module.h>
......@@ -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 )
{
......
......@@ -12,6 +12,7 @@
#include <worksheet.h>
#include <pcbstruct.h>
#include <macros.h>
#include <base_units.h>
#include <class_board.h>
......@@ -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;
}
}
......
......@@ -7,6 +7,7 @@
#include <common.h>
#include <class_drawpanel.h>
#include <wxBasePcbFrame.h>
#include <base_units.h>
#include <pcbnew.h>
#include <pcbnew_id.h>
......@@ -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 )
......
......@@ -6,6 +6,7 @@
#include <appl_wxstruct.h>
#include <confirm.h>
#include <wxPcbStruct.h>
#include <base_units.h>
#include <class_board.h>
#include <class_zone.h>
......@@ -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 )
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment