diff --git a/3d-viewer/3d_aux.cpp b/3d-viewer/3d_aux.cpp index ceb7ba9711..865e199b17 100644 --- a/3d-viewer/3d_aux.cpp +++ b/3d-viewer/3d_aux.cpp @@ -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) ); /* 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].y += m_MatPosition.y * SCALE_3D_CONV; aVertices[ii].z += m_MatPosition.z * SCALE_3D_CONV; diff --git a/common/base_units.cpp b/common/base_units.cpp index a871a0d7ba..478bdca6e3 100644 --- a/common/base_units.cpp +++ b/common/base_units.cpp @@ -67,6 +67,11 @@ double To_User_Unit( EDA_UNITS_T aUnit, double aValue ) wxString CoordinateToString( int aValue, bool aConvertToMils ) +{ + return LengthDoubleToString( (double) aValue, aConvertToMils ); +} + +wxString LengthDoubleToString( double aValue, bool aConvertToMils ) { wxString text; const wxChar* format; @@ -249,3 +254,14 @@ int ReturnValueFromTextCtrl( const wxTextCtrl& aTextCtr ) return value; } + + +wxString& operator <<( wxString& aString, const wxPoint& aPos ) +{ + aString << wxT( "@ (" ) << CoordinateToString( aPos.x ); + aString << wxT( "," ) << CoordinateToString( aPos.y ); + aString << wxT( ")" ); + + return aString; +} + diff --git a/common/common.cpp b/common/common.cpp index 2697a6dae8..c3f298c3e3 100644 --- a/common/common.cpp +++ b/common/common.cpp @@ -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 ) { assert( precision != 0 ); diff --git a/common/drawframe.cpp b/common/drawframe.cpp index 656589cbf1..2078fdc4d3 100644 --- a/common/drawframe.cpp +++ b/common/drawframe.cpp @@ -584,6 +584,11 @@ wxString EDA_DRAW_FRAME::CoordinateToString( int aValue, bool 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 ) { diff --git a/eeschema/class_drc_erc_item.cpp b/eeschema/class_drc_erc_item.cpp index d9e1a0c2d9..928d72e9bf 100644 --- a/eeschema/class_drc_erc_item.cpp +++ b/eeschema/class_drc_erc_item.cpp @@ -30,6 +30,7 @@ #include #include +#include wxString DRC_ITEM::GetErrorText() const { @@ -57,14 +58,9 @@ wxString DRC_ITEM::GetErrorText() const } } - wxString DRC_ITEM::ShowCoord( const wxPoint& aPos ) { wxString ret; - wxPoint pos_in_pcb_units = aPos; - pos_in_pcb_units.x *= 10; - pos_in_pcb_units.y *= 10; - ret << pos_in_pcb_units; + ret << aPos; return ret; } - diff --git a/include/base_units.h b/include/base_units.h index 16276e64fb..790025fff8 100644 --- a/include/base_units.h +++ b/include/base_units.h @@ -50,16 +50,27 @@ 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, + * 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. * - * @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 * the current user unit is millimeters. * @return The converted string for display in user interface elements. */ 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 @@ -72,6 +83,16 @@ wxString CoordinateToString( int aValue, bool aConvertToMils = 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 * converts \a aValue from internal units to user units and append the units notation diff --git a/include/common.h b/include/common.h index 3323ca7b9b..3a1fed59f6 100644 --- a/include/common.h +++ b/include/common.h @@ -541,17 +541,6 @@ private: 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 * runs a child process. @@ -583,14 +572,6 @@ int GetCommandOptions( const int argc, const char** argv, const char* stringtst, const char** optarg, 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. * diff --git a/include/fctsys.h b/include/fctsys.h index 648baa5926..8225dfd0f3 100644 --- a/include/fctsys.h +++ b/include/fctsys.h @@ -29,9 +29,6 @@ #define M_PI 3.141592653 #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__ #define DIR_SEP '\\' #define STRING_DIR_SEP wxT( "\\" ) diff --git a/include/wxstruct.h b/include/wxstruct.h index 9577af8dfa..39df566219 100644 --- a/include/wxstruct.h +++ b/include/wxstruct.h @@ -841,7 +841,7 @@ public: /** * 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. * @param aValue The coordinate to convert. * @param aConvertToMils Convert inch values to mils if true. This setting has no effect if @@ -850,6 +850,17 @@ public: */ 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() }; diff --git a/pcbnew/class_dimension.cpp b/pcbnew/class_dimension.cpp index 51af0595ed..49083ed105 100644 --- a/pcbnew/class_dimension.cpp +++ b/pcbnew/class_dimension.cpp @@ -41,6 +41,7 @@ #include #include #include +#include DIMENSION::DIMENSION( BOARD_ITEM* aParent ) : @@ -344,7 +345,7 @@ void DIMENSION::AdjustDimensionDetails( bool aDoNotChangeText ) if( !aDoNotChangeText ) { m_Value = mesure; - valeur_param( m_Value, msg ); + msg = ::CoordinateToString( m_Value ); SetText( msg ); } } diff --git a/pcbnew/class_drawsegment.cpp b/pcbnew/class_drawsegment.cpp index 0679b53ab4..a65ac9f05e 100644 --- a/pcbnew/class_drawsegment.cpp +++ b/pcbnew/class_drawsegment.cpp @@ -47,6 +47,7 @@ #include #include #include +#include DRAWSEGMENT::DRAWSEGMENT( BOARD_ITEM* aParent, KICAD_T idtype ) : @@ -373,7 +374,7 @@ void DRAWSEGMENT::DisplayInfo( EDA_DRAW_FRAME* frame ) frame->AppendMsgPanel( _( "Layer" ), board->GetLayerName( m_Layer ), DARKBROWN ); - valeur_param( (unsigned) m_Width, msg ); + msg = frame->CoordinateToString( m_Width ); frame->AppendMsgPanel( _( "Width" ), msg, DARKCYAN ); } @@ -527,12 +528,11 @@ bool DRAWSEGMENT::HitTest( const EDA_RECT& aRect ) const wxString DRAWSEGMENT::GetSelectMenuText() const { wxString text; - wxString temp; + wxString temp = ::LengthDoubleToString( GetLength() ); text.Printf( _( "Pcb Graphic: %s length: %s on %s" ), GetChars( ShowShape( (STROKE_T) m_Shape ) ), - GetChars( valeur_param( GetLength(), temp ) ), - GetChars( GetLayerName() ) ); + GetChars( temp ), GetChars( GetLayerName() ) ); return text; } diff --git a/pcbnew/class_drc_item.cpp b/pcbnew/class_drc_item.cpp index 92924300a7..402e3643af 100644 --- a/pcbnew/class_drc_item.cpp +++ b/pcbnew/class_drc_item.cpp @@ -32,6 +32,7 @@ #include #include #include +#include wxString DRC_ITEM::GetErrorText() const diff --git a/pcbnew/class_edge_mod.cpp b/pcbnew/class_edge_mod.cpp index b1ef13eef4..241f6182e0 100644 --- a/pcbnew/class_edge_mod.cpp +++ b/pcbnew/class_edge_mod.cpp @@ -255,7 +255,7 @@ void EDGE_MODULE::DisplayInfo( EDA_DRAW_FRAME* frame ) frame->AppendMsgPanel( _( "Mod Layer" ), board->GetLayerName( module->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 ); } diff --git a/pcbnew/class_mire.cpp b/pcbnew/class_mire.cpp index 18bfc99849..21f0840cd1 100644 --- a/pcbnew/class_mire.cpp +++ b/pcbnew/class_mire.cpp @@ -42,6 +42,7 @@ #include #include +#include PCB_TARGET::PCB_TARGET( BOARD_ITEM* aParent ) : @@ -210,7 +211,7 @@ wxString PCB_TARGET::GetSelectMenuText() const wxString text; wxString msg; - valeur_param( m_Size, msg ); + msg = ::CoordinateToString( m_Size ); text.Printf( _( "Target on %s size %s" ), GetChars( GetLayerName() ), GetChars( msg ) ); diff --git a/pcbnew/class_track.cpp b/pcbnew/class_track.cpp index 2ae5d9add1..e69eceb527 100644 --- a/pcbnew/class_track.cpp +++ b/pcbnew/class_track.cpp @@ -46,6 +46,7 @@ #include #include +#include /** * Function ShowClearance @@ -138,10 +139,7 @@ EDA_ITEM* TRACK::Clone() const wxString TRACK::ShowWidth() const { - wxString msg; - - valeur_param( m_Width, msg ); - + wxString msg = ::CoordinateToString( m_Width ); return msg; } @@ -1173,7 +1171,7 @@ void TRACK::DisplayInfoBase( EDA_DRAW_FRAME* frame ) // Display segment length 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 ); } } @@ -1553,7 +1551,7 @@ wxString TRACK::GetSelectMenuText() const } text << _( " on " ) << GetLayerName() << wxT(" ") << _("Net:") << GetNet() - << wxT(" ") << _("Length:") << valeur_param( GetLength(), temp ); + << wxT(" ") << _("Length:") << ::LengthDoubleToString( GetLength() ); return text; } diff --git a/pcbnew/editrack.cpp b/pcbnew/editrack.cpp index 269fe02e9b..ca3e87cd43 100644 --- a/pcbnew/editrack.cpp +++ b/pcbnew/editrack.cpp @@ -789,13 +789,13 @@ void ShowNewTrackWhenMovingCursor( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPo for( TRACK* track = g_FirstTrackSegment; track; track = track->Next() ) trackLen += track->GetLength(); - valeur_param( KiROUND( trackLen ), msg ); + msg = frame->LengthDoubleToString( trackLen ); frame->AppendMsgPanel( _( "Track Len" ), msg, DARKCYAN ); if( lenDie != 0 ) // display the track len on board and the actual track len { frame->AppendMsgPanel( _( "Full Len" ), msg, DARKCYAN ); - valeur_param( KiROUND( trackLen+lenDie ), msg ); + msg = frame->LengthDoubleToString( trackLen+lenDie ); frame->AppendMsgPanel( _( "On Die" ), msg, DARKCYAN ); } diff --git a/pcbnew/specctra_export.cpp b/pcbnew/specctra_export.cpp index 656fea3c7c..3ced90fe48 100644 --- a/pcbnew/specctra_export.cpp +++ b/pcbnew/specctra_export.cpp @@ -48,6 +48,7 @@ #include #include #include +#include #include