Minor fixes and cleanup
This commit is contained in:
parent
4343eb5b8d
commit
7a5386a1a1
|
@ -124,6 +124,31 @@ wxString LengthDoubleToString( double aValue, bool aConvertToMils )
|
||||||
return text;
|
return text;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Remove trailing 0 from a string containing a converted float number.
|
||||||
|
* the trailing 0 are removed if the mantissa has more
|
||||||
|
* than aTrailingZeroAllowed digits and some trailing 0
|
||||||
|
*/
|
||||||
|
void StripTrailingZeros( wxString& aStringValue, unsigned aTrailingZeroAllowed )
|
||||||
|
{
|
||||||
|
struct lconv * lc = localeconv();
|
||||||
|
char sep = lc->decimal_point[0];
|
||||||
|
unsigned sep_pos = aStringValue.Find( sep );
|
||||||
|
|
||||||
|
if( sep_pos > 0 )
|
||||||
|
{
|
||||||
|
// We want to keep at least aTrailingZeroAllowed digits after the separator
|
||||||
|
unsigned min_len = sep_pos + aTrailingZeroAllowed + 1;
|
||||||
|
|
||||||
|
while( aStringValue.Len() > min_len )
|
||||||
|
{
|
||||||
|
if( aStringValue.Last() == '0' )
|
||||||
|
aStringValue.RemoveLast();
|
||||||
|
else
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/* Convert a value to a string using double notation.
|
/* Convert a value to a string using double notation.
|
||||||
* For readability, the mantissa has 3 or more digits (max 8 digits),
|
* For readability, the mantissa has 3 or more digits (max 8 digits),
|
||||||
|
@ -153,21 +178,7 @@ wxString ReturnStringFromValue( EDA_UNITS_T aUnit, int aValue, bool aAddUnitSymb
|
||||||
|
|
||||||
// Strip trailing zeros. However, keep at least 3 digits in mantissa
|
// Strip trailing zeros. However, keep at least 3 digits in mantissa
|
||||||
// For readability
|
// For readability
|
||||||
struct lconv * lc = localeconv();
|
StripTrailingZeros( stringValue, 3 );
|
||||||
char sep = lc->decimal_point[0];
|
|
||||||
unsigned sep_pos = stringValue.Find( sep );
|
|
||||||
|
|
||||||
if( sep_pos > 0 )
|
|
||||||
{
|
|
||||||
// We want to keep at least 3 digits after the separator
|
|
||||||
unsigned min_len = sep_pos + 4;
|
|
||||||
|
|
||||||
while( stringValue.Len() > min_len )
|
|
||||||
if( stringValue.Last() == '0' )
|
|
||||||
stringValue.RemoveLast();
|
|
||||||
else
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if( aAddUnitSymbol )
|
if( aAddUnitSymbol )
|
||||||
|
|
|
@ -7,9 +7,9 @@
|
||||||
|
|
||||||
#ifndef KICAD_BUILD_VERSION
|
#ifndef KICAD_BUILD_VERSION
|
||||||
#if defined KICAD_GOST
|
#if defined KICAD_GOST
|
||||||
# define KICAD_BUILD_VERSION "(2013-feb-21 GOST)"
|
# define KICAD_BUILD_VERSION "(2013-feb-26 GOST)"
|
||||||
#else
|
#else
|
||||||
# define KICAD_BUILD_VERSION "(2013-feb-21)"
|
# define KICAD_BUILD_VERSION "(2013-feb-26)"
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -304,23 +304,6 @@ bool WildCompareString( const wxString& pattern, const wxString& string_to_tst,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
char* to_point( char* Text )
|
|
||||||
{
|
|
||||||
char* line = Text;
|
|
||||||
|
|
||||||
if( Text == NULL )
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
for( ; *Text != 0; Text++ )
|
|
||||||
{
|
|
||||||
if( *Text == ',' )
|
|
||||||
*Text = '.';
|
|
||||||
}
|
|
||||||
|
|
||||||
return line;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
int RefDesStringCompare( const wxString& strFWord, const wxString& strSWord )
|
int RefDesStringCompare( const wxString& strFWord, const wxString& strSWord )
|
||||||
{
|
{
|
||||||
// The different sections of the first string
|
// The different sections of the first string
|
||||||
|
|
|
@ -32,7 +32,6 @@
|
||||||
#include <class_drawpanel.h>
|
#include <class_drawpanel.h>
|
||||||
#include <class_sch_screen.h>
|
#include <class_sch_screen.h>
|
||||||
#include <wxEeschemaStruct.h>
|
#include <wxEeschemaStruct.h>
|
||||||
#include <dcsvg.h>
|
|
||||||
#include <base_units.h>
|
#include <base_units.h>
|
||||||
#include <libeditframe.h>
|
#include <libeditframe.h>
|
||||||
#include <sch_sheet_path.h>
|
#include <sch_sheet_path.h>
|
||||||
|
|
|
@ -290,7 +290,14 @@ void LIB_EDIT_FRAME::StartMoveDrawSymbol( wxDC* DC )
|
||||||
SetCursor( wxCURSOR_HAND );
|
SetCursor( wxCURSOR_HAND );
|
||||||
|
|
||||||
TempCopyComponent();
|
TempCopyComponent();
|
||||||
m_drawItem->BeginEdit( IS_MOVED, GetScreen()->GetCrossHairPosition( true ) );
|
|
||||||
|
// For fields only, move the anchor point of the field
|
||||||
|
// to the cursor position to allow user to see the text justification
|
||||||
|
if( m_drawItem->Type() == LIB_FIELD_T )
|
||||||
|
m_drawItem->BeginEdit( IS_MOVED, m_drawItem->GetPosition() );
|
||||||
|
else
|
||||||
|
m_drawItem->BeginEdit( IS_MOVED, GetScreen()->GetCrossHairPosition( true ) );
|
||||||
|
|
||||||
m_canvas->SetMouseCapture( RedrawWhileMovingCursor, AbortSymbolTraceOn );
|
m_canvas->SetMouseCapture( RedrawWhileMovingCursor, AbortSymbolTraceOn );
|
||||||
m_canvas->CallMouseCapture( DC, wxDefaultPosition, true );
|
m_canvas->CallMouseCapture( DC, wxDefaultPosition, true );
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,6 +37,14 @@
|
||||||
#include <common.h>
|
#include <common.h>
|
||||||
#include <convert_to_biu.h>
|
#include <convert_to_biu.h>
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Function StripTrailingZeros
|
||||||
|
* Remove trailing 0 from a string containing a converted float number.
|
||||||
|
* The trailing 0 are removed if the mantissa has more
|
||||||
|
* than aTrailingZeroAllowed digits and some trailing 0
|
||||||
|
*/
|
||||||
|
void StripTrailingZeros( wxString& aStringValue, unsigned aTrailingZeroAllowed = 1 );
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function To_User_Unit
|
* Function To_User_Unit
|
||||||
|
|
|
@ -98,14 +98,6 @@ bool WildCompareString( const wxString& pattern,
|
||||||
const wxString& string_to_tst,
|
const wxString& string_to_tst,
|
||||||
bool case_sensitive = true );
|
bool case_sensitive = true );
|
||||||
|
|
||||||
/**
|
|
||||||
* Function to_point
|
|
||||||
* converts a string used to compensate for internalization of printf(). It generates
|
|
||||||
* floating point numbers with a comma instead of point.
|
|
||||||
* @deprecated Use SetLocaleTo_C_standard instead.
|
|
||||||
*/
|
|
||||||
char* to_point( char* Text );
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function RefDesStringCompare
|
* Function RefDesStringCompare
|
||||||
* acts just like the strcmp function but treats numbers within the string text
|
* acts just like the strcmp function but treats numbers within the string text
|
||||||
|
|
|
@ -761,16 +761,13 @@ void PCB_BASE_FRAME::updateGridSelectBox()
|
||||||
m_gridSelectBox->Clear();
|
m_gridSelectBox->Clear();
|
||||||
|
|
||||||
wxString msg;
|
wxString msg;
|
||||||
wxString format = _( "Grid");
|
wxString format = _( "Grid:");
|
||||||
|
|
||||||
switch( g_UserUnit )
|
switch( g_UserUnit )
|
||||||
{
|
{
|
||||||
case INCHES:
|
case INCHES: // the grid size is displayed in mils
|
||||||
format += wxT( " %.1f" );
|
|
||||||
break;
|
|
||||||
|
|
||||||
case MILLIMETRES:
|
case MILLIMETRES:
|
||||||
format += wxT( " %.4f" );
|
format += wxT( " %.6f" );
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case UNSCALED_UNITS:
|
case UNSCALED_UNITS:
|
||||||
|
@ -782,20 +779,13 @@ void PCB_BASE_FRAME::updateGridSelectBox()
|
||||||
{
|
{
|
||||||
GRID_TYPE& grid = GetScreen()->GetGrid( i );
|
GRID_TYPE& grid = GetScreen()->GetGrid( i );
|
||||||
double value = To_User_Unit( g_UserUnit, grid.m_Size.x );
|
double value = To_User_Unit( g_UserUnit, grid.m_Size.x );
|
||||||
|
if( g_UserUnit == INCHES )
|
||||||
|
value *= 1000;
|
||||||
|
|
||||||
if( grid.m_Id != ID_POPUP_GRID_USER )
|
if( grid.m_Id != ID_POPUP_GRID_USER )
|
||||||
{
|
{
|
||||||
switch( g_UserUnit )
|
msg.Printf( format.GetData(), value );
|
||||||
{
|
StripTrailingZeros( msg );
|
||||||
case INCHES:
|
|
||||||
msg.Printf( format.GetData(), value * 1000 );
|
|
||||||
break;
|
|
||||||
|
|
||||||
case MILLIMETRES:
|
|
||||||
case UNSCALED_UNITS:
|
|
||||||
msg.Printf( format.GetData(), value );
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
msg = _( "User Grid" );
|
msg = _( "User Grid" );
|
||||||
|
|
|
@ -31,7 +31,6 @@
|
||||||
#include <appl_wxstruct.h>
|
#include <appl_wxstruct.h>
|
||||||
#include <common.h>
|
#include <common.h>
|
||||||
#include <class_drawpanel.h>
|
#include <class_drawpanel.h>
|
||||||
#include <dcsvg.h>
|
|
||||||
#include <wxBasePcbFrame.h>
|
#include <wxBasePcbFrame.h>
|
||||||
#include <class_pcb_screen.h>
|
#include <class_pcb_screen.h>
|
||||||
#include <base_units.h>
|
#include <base_units.h>
|
||||||
|
|
|
@ -2,6 +2,28 @@
|
||||||
* @file set_grid.cpp
|
* @file set_grid.cpp
|
||||||
* @brief Manage user grid.
|
* @brief Manage user grid.
|
||||||
*/
|
*/
|
||||||
|
/*
|
||||||
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||||
|
*
|
||||||
|
* Copyright (C) 1992-2013 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
|
||||||
|
*/
|
||||||
|
|
||||||
#include <fctsys.h>
|
#include <fctsys.h>
|
||||||
#include <common.h>
|
#include <common.h>
|
||||||
|
@ -83,9 +105,9 @@ void DIALOG_SET_GRID::SetGridSize( const wxRealPoint& grid )
|
||||||
{
|
{
|
||||||
wxString msg;
|
wxString msg;
|
||||||
|
|
||||||
msg.Printf( wxT( "%.4f" ), grid.x );
|
msg.Printf( wxT( "%.6f" ), grid.x );
|
||||||
m_OptGridSizeX->SetValue( msg );
|
m_OptGridSizeX->SetValue( msg );
|
||||||
msg.Printf( wxT( "%.4f" ), grid.y );
|
msg.Printf( wxT( "%.6f" ), grid.y );
|
||||||
m_OptGridSizeY->SetValue( msg );
|
m_OptGridSizeY->SetValue( msg );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -138,11 +160,8 @@ void DIALOG_SET_GRID::SetGridOrigin( const wxPoint& grid )
|
||||||
|
|
||||||
void DIALOG_SET_GRID::SetGridForFastSwitching( wxArrayString aGrids, int aGrid1, int aGrid2 )
|
void DIALOG_SET_GRID::SetGridForFastSwitching( wxArrayString aGrids, int aGrid1, int aGrid2 )
|
||||||
{
|
{
|
||||||
for( wxArrayString::iterator i = aGrids.begin(); i != aGrids.end(); i++ )
|
m_comboBoxGrid1->Append( aGrids );
|
||||||
{
|
m_comboBoxGrid2->Append( aGrids );
|
||||||
m_comboBoxGrid1->Append( *i );
|
|
||||||
m_comboBoxGrid2->Append( *i );
|
|
||||||
}
|
|
||||||
|
|
||||||
m_comboBoxGrid1->SetSelection( aGrid1 );
|
m_comboBoxGrid1->SetSelection( aGrid1 );
|
||||||
m_comboBoxGrid2->SetSelection( aGrid2 );
|
m_comboBoxGrid2->SetSelection( aGrid2 );
|
||||||
|
|
Loading…
Reference in New Issue