Commit e96f1aeb authored by jean-pierre charras's avatar jean-pierre charras

Remove valeur_param(), that does not work in Kicad Nanometer

parent 9d6c1d12
...@@ -70,7 +70,7 @@ void S3D_MASTER::Set_Object_Coords( std::vector< S3D_Vertex >& aVertices ) ...@@ -70,7 +70,7 @@ void S3D_MASTER::Set_Object_Coords( std::vector< S3D_Vertex >& aVertices )
RotatePoint( &aVertices[ii].x, &aVertices[ii].y, (int) (m_MatRotation.z * 10) ); RotatePoint( &aVertices[ii].x, &aVertices[ii].y, (int) (m_MatRotation.z * 10) );
/* adjust offset position (offset is given in UNIT 3D (0.1 inch) */ /* adjust offset position (offset is given in UNIT 3D (0.1 inch) */
#define SCALE_3D_CONV (PCB_INTERNAL_UNIT / UNITS3D_TO_UNITSPCB) #define SCALE_3D_CONV ((IU_PER_MILS * 1000) / UNITS3D_TO_UNITSPCB)
aVertices[ii].x += m_MatPosition.x * SCALE_3D_CONV; aVertices[ii].x += m_MatPosition.x * SCALE_3D_CONV;
aVertices[ii].y += m_MatPosition.y * SCALE_3D_CONV; aVertices[ii].y += m_MatPosition.y * SCALE_3D_CONV;
aVertices[ii].z += m_MatPosition.z * SCALE_3D_CONV; aVertices[ii].z += m_MatPosition.z * SCALE_3D_CONV;
......
...@@ -67,6 +67,11 @@ double To_User_Unit( EDA_UNITS_T aUnit, double aValue ) ...@@ -67,6 +67,11 @@ double To_User_Unit( EDA_UNITS_T aUnit, double aValue )
wxString CoordinateToString( int aValue, bool aConvertToMils ) wxString CoordinateToString( int aValue, bool aConvertToMils )
{
return LengthDoubleToString( (double) aValue, aConvertToMils );
}
wxString LengthDoubleToString( double aValue, bool aConvertToMils )
{ {
wxString text; wxString text;
const wxChar* format; const wxChar* format;
...@@ -249,3 +254,14 @@ int ReturnValueFromTextCtrl( const wxTextCtrl& aTextCtr ) ...@@ -249,3 +254,14 @@ int ReturnValueFromTextCtrl( const wxTextCtrl& aTextCtr )
return value; return value;
} }
wxString& operator <<( wxString& aString, const wxPoint& aPos )
{
aString << wxT( "@ (" ) << CoordinateToString( aPos.x );
aString << wxT( "," ) << CoordinateToString( aPos.y );
aString << wxT( ")" );
return aString;
}
...@@ -334,39 +334,6 @@ unsigned long GetNewTimeStamp() ...@@ -334,39 +334,6 @@ unsigned long GetNewTimeStamp()
} }
const wxString& valeur_param( int valeur, wxString& buf_texte )
{
switch( g_UserUnit )
{
case MILLIMETRES:
buf_texte.Printf( _( "%3.3f mm" ), valeur * 0.00254 );
break;
case INCHES:
buf_texte.Printf( wxT( "%2.4f \"" ), valeur * 0.0001 );
break;
case UNSCALED_UNITS:
buf_texte.Printf( wxT( "%d" ), valeur );
break;
}
return buf_texte;
}
wxString& operator <<( wxString& aString, const wxPoint& aPos )
{
wxString temp;
aString << wxT( "@ (" ) << valeur_param( aPos.x, temp );
aString << wxT( "," ) << valeur_param( aPos.y, temp );
aString << wxT( ")" );
return aString;
}
double RoundTo0( double x, double precision ) double RoundTo0( double x, double precision )
{ {
assert( precision != 0 ); assert( precision != 0 );
......
...@@ -584,6 +584,11 @@ wxString EDA_DRAW_FRAME::CoordinateToString( int aValue, bool aConvertToMils ) ...@@ -584,6 +584,11 @@ wxString EDA_DRAW_FRAME::CoordinateToString( int aValue, bool aConvertToMils )
return ::CoordinateToString( aValue, aConvertToMils ); return ::CoordinateToString( aValue, aConvertToMils );
} }
wxString EDA_DRAW_FRAME::LengthDoubleToString( double aValue, bool aConvertToMils )
{
return ::LengthDoubleToString( aValue, aConvertToMils );
}
bool EDA_DRAW_FRAME::HandleBlockBegin( wxDC* aDC, int aKey, const wxPoint& aPosition ) bool EDA_DRAW_FRAME::HandleBlockBegin( wxDC* aDC, int aKey, const wxPoint& aPosition )
{ {
......
...@@ -30,6 +30,7 @@ ...@@ -30,6 +30,7 @@
#include <class_drc_item.h> #include <class_drc_item.h>
#include <erc.h> #include <erc.h>
#include <base_units.h>
wxString DRC_ITEM::GetErrorText() const wxString DRC_ITEM::GetErrorText() const
{ {
...@@ -57,14 +58,9 @@ wxString DRC_ITEM::GetErrorText() const ...@@ -57,14 +58,9 @@ wxString DRC_ITEM::GetErrorText() const
} }
} }
wxString DRC_ITEM::ShowCoord( const wxPoint& aPos ) wxString DRC_ITEM::ShowCoord( const wxPoint& aPos )
{ {
wxString ret; wxString ret;
wxPoint pos_in_pcb_units = aPos; ret << aPos;
pos_in_pcb_units.x *= 10;
pos_in_pcb_units.y *= 10;
ret << pos_in_pcb_units;
return ret; return ret;
} }
...@@ -50,16 +50,27 @@ double To_User_Unit( EDA_UNITS_T aUnit, double aValue ); ...@@ -50,16 +50,27 @@ double To_User_Unit( EDA_UNITS_T aUnit, double aValue );
/** /**
* Function CoordinateToString * Function CoordinateToString
* is a helper to convert the integer coordinate \a aValue to a string in inches, * is a helper to convert the \a integer coordinate \a aValue to a string in inches,
* millimeters, or unscaled units according to the current user units setting. * millimeters, or unscaled units according to the current user units setting.
* *
* @param aValue The coordinate to convert. * @param aValue The integer coordinate to convert.
* @param aConvertToMils Convert inch values to mils if true. This setting has no effect if * @param aConvertToMils Convert inch values to mils if true. This setting has no effect if
* the current user unit is millimeters. * the current user unit is millimeters.
* @return The converted string for display in user interface elements. * @return The converted string for display in user interface elements.
*/ */
wxString CoordinateToString( int aValue, bool aConvertToMils = false ); wxString CoordinateToString( int aValue, bool aConvertToMils = false );
/**
* Function LenghtDoubleToString
* is a helper to convert the \a double length \a aValue to a string in inches,
* millimeters, or unscaled units according to the current user units setting.
*
* @param aValue The double value 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 LengthDoubleToString( double aValue, bool aConvertToMils = false );
/** /**
* Function ReturnStringFromValue * Function ReturnStringFromValue
...@@ -72,6 +83,16 @@ wxString CoordinateToString( int aValue, bool aConvertToMils = false ); ...@@ -72,6 +83,16 @@ wxString CoordinateToString( int aValue, bool aConvertToMils = false );
*/ */
wxString ReturnStringFromValue( EDA_UNITS_T aUnit, int aValue, bool aAddUnitSymbol = false ); wxString ReturnStringFromValue( EDA_UNITS_T aUnit, int aValue, bool aAddUnitSymbol = false );
/**
* Operator << overload
* outputs a point to the argument string in a format resembling
* "@ (x,y)
* @param aString Where to put the text describing the point value
* @param aPoint The point to output.
* @return wxString& - the input string
*/
wxString& operator <<( wxString& aString, const wxPoint& aPoint );
/** /**
* Function PutValueInLocalUnits * Function PutValueInLocalUnits
* converts \a aValue from internal units to user units and append the units notation * converts \a aValue from internal units to user units and append the units notation
......
...@@ -541,17 +541,6 @@ private: ...@@ -541,17 +541,6 @@ private:
bool EnsureTextCtrlWidth( wxTextCtrl* aCtrl, const wxString* aString = NULL ); bool EnsureTextCtrlWidth( wxTextCtrl* aCtrl, const wxString* aString = NULL );
/**
* Operator << overload
* outputs a point to the argument string in a format resembling
* "@ (x,y)
* @param aString Where to put the text describing the point value
* @param aPoint The point to output.
* @return wxString& - the input string
*/
wxString& operator <<( wxString& aString, const wxPoint& aPoint );
/** /**
* Function ProcessExecute * Function ProcessExecute
* runs a child process. * runs a child process.
...@@ -583,14 +572,6 @@ int GetCommandOptions( const int argc, const char** argv, ...@@ -583,14 +572,6 @@ int GetCommandOptions( const int argc, const char** argv,
const char* stringtst, const char** optarg, const char* stringtst, const char** optarg,
int* optind ); int* optind );
/* Returns to display the value of a parameter, by type of units selected
* Input: value in mils, buffer text
* Returns to buffer: text: value expressed in inches or millimeters
* Followed by " or mm
*/
const wxString& valeur_param( int valeur, wxString& buf_texte );
/** /**
* Returns the units symbol. * Returns the units symbol.
* *
......
...@@ -29,9 +29,6 @@ ...@@ -29,9 +29,6 @@
#define M_PI 3.141592653 #define M_PI 3.141592653
#endif #endif
#define PCB_INTERNAL_UNIT 10000 // PCBNEW internal unit = 1/10000 inch
#define EESCHEMA_INTERNAL_UNIT 1000 // EESCHEMA internal unit = 1/1000 inch
#ifdef __WINDOWS__ #ifdef __WINDOWS__
#define DIR_SEP '\\' #define DIR_SEP '\\'
#define STRING_DIR_SEP wxT( "\\" ) #define STRING_DIR_SEP wxT( "\\" )
......
...@@ -841,7 +841,7 @@ public: ...@@ -841,7 +841,7 @@ public:
/** /**
* Function CoordinateToString * Function CoordinateToString
* is a helper to convert the integer coordinate \a aValue to a string in inches or mm * is a helper to convert the \a integer coordinate \a aValue to a string in inches or mm
* according to the current user units setting. * according to the current user units setting.
* @param aValue The coordinate to convert. * @param aValue The coordinate to convert.
* @param aConvertToMils Convert inch values to mils if true. This setting has no effect if * @param aConvertToMils Convert inch values to mils if true. This setting has no effect if
...@@ -850,6 +850,17 @@ public: ...@@ -850,6 +850,17 @@ public:
*/ */
wxString CoordinateToString( int aValue, bool aConvertToMils = false ); wxString CoordinateToString( int aValue, bool aConvertToMils = false );
/**
* Function LengthDoubleToString
* is a helper to convert the \a double value \a aValue to a string in inches or mm
* 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 LengthDoubleToString( double aValue, bool aConvertToMils = false );
DECLARE_EVENT_TABLE() DECLARE_EVENT_TABLE()
}; };
......
...@@ -41,6 +41,7 @@ ...@@ -41,6 +41,7 @@
#include <class_board.h> #include <class_board.h>
#include <class_pcb_text.h> #include <class_pcb_text.h>
#include <class_dimension.h> #include <class_dimension.h>
#include <base_units.h>
DIMENSION::DIMENSION( BOARD_ITEM* aParent ) : DIMENSION::DIMENSION( BOARD_ITEM* aParent ) :
...@@ -344,7 +345,7 @@ void DIMENSION::AdjustDimensionDetails( bool aDoNotChangeText ) ...@@ -344,7 +345,7 @@ void DIMENSION::AdjustDimensionDetails( bool aDoNotChangeText )
if( !aDoNotChangeText ) if( !aDoNotChangeText )
{ {
m_Value = mesure; m_Value = mesure;
valeur_param( m_Value, msg ); msg = ::CoordinateToString( m_Value );
SetText( msg ); SetText( msg );
} }
} }
......
...@@ -47,6 +47,7 @@ ...@@ -47,6 +47,7 @@
#include <class_board.h> #include <class_board.h>
#include <class_module.h> #include <class_module.h>
#include <class_drawsegment.h> #include <class_drawsegment.h>
#include <base_units.h>
DRAWSEGMENT::DRAWSEGMENT( BOARD_ITEM* aParent, KICAD_T idtype ) : DRAWSEGMENT::DRAWSEGMENT( BOARD_ITEM* aParent, KICAD_T idtype ) :
...@@ -373,7 +374,7 @@ void DRAWSEGMENT::DisplayInfo( EDA_DRAW_FRAME* frame ) ...@@ -373,7 +374,7 @@ void DRAWSEGMENT::DisplayInfo( EDA_DRAW_FRAME* frame )
frame->AppendMsgPanel( _( "Layer" ), board->GetLayerName( m_Layer ), DARKBROWN ); frame->AppendMsgPanel( _( "Layer" ), board->GetLayerName( m_Layer ), DARKBROWN );
valeur_param( (unsigned) m_Width, msg ); msg = frame->CoordinateToString( m_Width );
frame->AppendMsgPanel( _( "Width" ), msg, DARKCYAN ); frame->AppendMsgPanel( _( "Width" ), msg, DARKCYAN );
} }
...@@ -527,12 +528,11 @@ bool DRAWSEGMENT::HitTest( const EDA_RECT& aRect ) const ...@@ -527,12 +528,11 @@ bool DRAWSEGMENT::HitTest( const EDA_RECT& aRect ) const
wxString DRAWSEGMENT::GetSelectMenuText() const wxString DRAWSEGMENT::GetSelectMenuText() const
{ {
wxString text; wxString text;
wxString temp; wxString temp = ::LengthDoubleToString( GetLength() );
text.Printf( _( "Pcb Graphic: %s length: %s on %s" ), text.Printf( _( "Pcb Graphic: %s length: %s on %s" ),
GetChars( ShowShape( (STROKE_T) m_Shape ) ), GetChars( ShowShape( (STROKE_T) m_Shape ) ),
GetChars( valeur_param( GetLength(), temp ) ), GetChars( temp ), GetChars( GetLayerName() ) );
GetChars( GetLayerName() ) );
return text; return text;
} }
......
...@@ -32,6 +32,7 @@ ...@@ -32,6 +32,7 @@
#include <pcbnew.h> #include <pcbnew.h>
#include <drc_stuff.h> #include <drc_stuff.h>
#include <class_drc_item.h> #include <class_drc_item.h>
#include <base_units.h>
wxString DRC_ITEM::GetErrorText() const wxString DRC_ITEM::GetErrorText() const
......
...@@ -255,7 +255,7 @@ void EDGE_MODULE::DisplayInfo( EDA_DRAW_FRAME* frame ) ...@@ -255,7 +255,7 @@ void EDGE_MODULE::DisplayInfo( EDA_DRAW_FRAME* frame )
frame->AppendMsgPanel( _( "Mod Layer" ), board->GetLayerName( module->GetLayer() ), RED ); frame->AppendMsgPanel( _( "Mod Layer" ), board->GetLayerName( module->GetLayer() ), RED );
frame->AppendMsgPanel( _( "Seg Layer" ), board->GetLayerName( GetLayer() ), RED ); frame->AppendMsgPanel( _( "Seg Layer" ), board->GetLayerName( GetLayer() ), RED );
valeur_param( m_Width, msg ); msg = frame->CoordinateToString( m_Width );
frame->AppendMsgPanel( _( "Width" ), msg, BLUE ); frame->AppendMsgPanel( _( "Width" ), msg, BLUE );
} }
......
...@@ -42,6 +42,7 @@ ...@@ -42,6 +42,7 @@
#include <class_board.h> #include <class_board.h>
#include <class_mire.h> #include <class_mire.h>
#include <base_units.h>
PCB_TARGET::PCB_TARGET( BOARD_ITEM* aParent ) : PCB_TARGET::PCB_TARGET( BOARD_ITEM* aParent ) :
...@@ -210,7 +211,7 @@ wxString PCB_TARGET::GetSelectMenuText() const ...@@ -210,7 +211,7 @@ wxString PCB_TARGET::GetSelectMenuText() const
wxString text; wxString text;
wxString msg; wxString msg;
valeur_param( m_Size, msg ); msg = ::CoordinateToString( m_Size );
text.Printf( _( "Target on %s size %s" ), text.Printf( _( "Target on %s size %s" ),
GetChars( GetLayerName() ), GetChars( msg ) ); GetChars( GetLayerName() ), GetChars( msg ) );
......
...@@ -46,6 +46,7 @@ ...@@ -46,6 +46,7 @@
#include <pcbnew.h> #include <pcbnew.h>
#include <protos.h> #include <protos.h>
#include <base_units.h>
/** /**
* Function ShowClearance * Function ShowClearance
...@@ -138,10 +139,7 @@ EDA_ITEM* TRACK::Clone() const ...@@ -138,10 +139,7 @@ EDA_ITEM* TRACK::Clone() const
wxString TRACK::ShowWidth() const wxString TRACK::ShowWidth() const
{ {
wxString msg; wxString msg = ::CoordinateToString( m_Width );
valeur_param( m_Width, msg );
return msg; return msg;
} }
...@@ -1173,7 +1171,7 @@ void TRACK::DisplayInfoBase( EDA_DRAW_FRAME* frame ) ...@@ -1173,7 +1171,7 @@ void TRACK::DisplayInfoBase( EDA_DRAW_FRAME* frame )
// Display segment length // Display segment length
if( Type() != PCB_VIA_T ) // Display Diam and Drill values if( Type() != PCB_VIA_T ) // Display Diam and Drill values
{ {
msg = frame->CoordinateToString( KiROUND( GetLength() ) ); msg = frame->LengthDoubleToString( GetLength() );
frame->AppendMsgPanel( _( "Segment Length" ), msg, DARKCYAN ); frame->AppendMsgPanel( _( "Segment Length" ), msg, DARKCYAN );
} }
} }
...@@ -1553,7 +1551,7 @@ wxString TRACK::GetSelectMenuText() const ...@@ -1553,7 +1551,7 @@ wxString TRACK::GetSelectMenuText() const
} }
text << _( " on " ) << GetLayerName() << wxT(" ") << _("Net:") << GetNet() text << _( " on " ) << GetLayerName() << wxT(" ") << _("Net:") << GetNet()
<< wxT(" ") << _("Length:") << valeur_param( GetLength(), temp ); << wxT(" ") << _("Length:") << ::LengthDoubleToString( GetLength() );
return text; return text;
} }
......
...@@ -789,13 +789,13 @@ void ShowNewTrackWhenMovingCursor( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPo ...@@ -789,13 +789,13 @@ void ShowNewTrackWhenMovingCursor( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPo
for( TRACK* track = g_FirstTrackSegment; track; track = track->Next() ) for( TRACK* track = g_FirstTrackSegment; track; track = track->Next() )
trackLen += track->GetLength(); trackLen += track->GetLength();
valeur_param( KiROUND( trackLen ), msg ); msg = frame->LengthDoubleToString( trackLen );
frame->AppendMsgPanel( _( "Track Len" ), msg, DARKCYAN ); frame->AppendMsgPanel( _( "Track Len" ), msg, DARKCYAN );
if( lenDie != 0 ) // display the track len on board and the actual track len if( lenDie != 0 ) // display the track len on board and the actual track len
{ {
frame->AppendMsgPanel( _( "Full Len" ), msg, DARKCYAN ); frame->AppendMsgPanel( _( "Full Len" ), msg, DARKCYAN );
valeur_param( KiROUND( trackLen+lenDie ), msg ); msg = frame->LengthDoubleToString( trackLen+lenDie );
frame->AppendMsgPanel( _( "On Die" ), msg, DARKCYAN ); frame->AppendMsgPanel( _( "On Die" ), msg, DARKCYAN );
} }
......
...@@ -48,6 +48,7 @@ ...@@ -48,6 +48,7 @@
#include <class_track.h> #include <class_track.h>
#include <class_zone.h> #include <class_zone.h>
#include <class_drawsegment.h> #include <class_drawsegment.h>
#include <base_units.h>
#include <collectors.h> #include <collectors.h>
......
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