Commit cb49ca5a authored by Lorenzo Marcantonio's avatar Lorenzo Marcantonio
Browse files

More int casts to rounding conversions

parent b2a76062
Loading
Loading
Loading
Loading
+3 −3
Original line number Original line Diff line number Diff line
@@ -39,9 +39,9 @@


// Thickness of copper
// Thickness of copper
// TODO: define the actual copper thickness by user
// TODO: define the actual copper thickness by user
#define COPPER_THICKNESS (int)(0.035 * IU_PER_MM)   // for 35 u
#define COPPER_THICKNESS KiROUND( 0.035 * IU_PER_MM )   // for 35 µm
#define TECH_LAYER_THICKNESS (int)(0.04 * IU_PER_MM)
#define TECH_LAYER_THICKNESS KiROUND( 0.04 * IU_PER_MM )
#define EPOXY_THICKNESS (int)(1.6 * IU_PER_MM)   // for 1.6 mm
#define EPOXY_THICKNESS KiROUND( 1.6 * IU_PER_MM )   // for 1.6 mm




/* INFO3D_VISU in an helper class to store parameters like scaling factors,
/* INFO3D_VISU in an helper class to store parameters like scaling factors,
+4 −4
Original line number Original line Diff line number Diff line
@@ -123,7 +123,7 @@ public: INFO3D_VISU();
     */
     */
    int GetLayerZcoordBIU( int aLayerId )
    int GetLayerZcoordBIU( int aLayerId )
    {
    {
        return (int) (m_LayerZcoord[aLayerId] / m_BiuTo3Dunits );
        return KiROUND( m_LayerZcoord[aLayerId] / m_BiuTo3Dunits );
    }
    }


    /**
    /**
@@ -137,7 +137,7 @@ public: INFO3D_VISU();
    int GetCopperThicknessBIU() const
    int GetCopperThicknessBIU() const
    {
    {
        return m_DrawFlags[FL_USE_COPPER_THICKNESS] ?
        return m_DrawFlags[FL_USE_COPPER_THICKNESS] ?
            (int) (m_CopperThickness / m_BiuTo3Dunits )
            KiROUND( m_CopperThickness / m_BiuTo3Dunits )
            : 0;
            : 0;
    }
    }


@@ -147,7 +147,7 @@ public: INFO3D_VISU();
     */
     */
    int GetEpoxyThicknessBIU() const
    int GetEpoxyThicknessBIU() const
    {
    {
        return (int) (m_EpoxyThickness / m_BiuTo3Dunits );
        return KiROUND( m_EpoxyThickness / m_BiuTo3Dunits );
    }
    }


    /**
    /**
@@ -160,7 +160,7 @@ public: INFO3D_VISU();
    int GetNonCopperLayerThicknessBIU() const
    int GetNonCopperLayerThicknessBIU() const
    {
    {
        return  m_DrawFlags[FL_USE_COPPER_THICKNESS] ?
        return  m_DrawFlags[FL_USE_COPPER_THICKNESS] ?
            (int) (m_NonCopperLayerThickness / m_BiuTo3Dunits )
            KiROUND( m_NonCopperLayerThickness / m_BiuTo3Dunits )
            : 0;
            : 0;
    }
    }


+1 −1
Original line number Original line Diff line number Diff line
@@ -389,7 +389,7 @@ void PLOTTER::segmentAsOval( const wxPoint& start, const wxPoint& end, int width
    else
    else
        orient = -ArcTangente( size.y, size.x );
        orient = -ArcTangente( size.y, size.x );


    size.x = KiROUND( hypot( size.x, size.y ) ) + width;
    size.x = KiROUND( EuclideanNorm( size ) ) + width;
    size.y = width;
    size.y = width;


    FlashPadOval( center, size, orient, tracemode );
    FlashPadOval( center, size, orient, tracemode );
+2 −2
Original line number Original line Diff line number Diff line
@@ -43,7 +43,7 @@
#include <transform.h>
#include <transform.h>


// Helper function
// Helper function
static inline wxPoint twoPointVector( wxPoint startPoint, wxPoint endPoint )
static inline wxPoint twoPointVector( const wxPoint &startPoint, const wxPoint &endPoint )
{
{
    return endPoint - startPoint;
    return endPoint - startPoint;
}
}
@@ -195,7 +195,7 @@ bool LIB_ARC::HitTest( wxPoint aPosition, int aThreshold, const TRANSFORM& aTran


    NEGATE( relativePosition.y );       // reverse Y axis
    NEGATE( relativePosition.y );       // reverse Y axis


    int distance = KiROUND( EuclideanNorm( twoPointVector( m_Pos, relativePosition ) ) );
    int distance = KiROUND( GetLineLength( m_Pos, relativePosition ) );


    if( abs( distance - m_Radius ) > aThreshold )
    if( abs( distance - m_Radius ) > aThreshold )
        return false;
        return false;
+2 −6
Original line number Original line Diff line number Diff line
@@ -105,9 +105,7 @@ bool LIB_CIRCLE::HitTest( wxPoint aPosRef, int aThreshold, const TRANSFORM& aTra
    if( aThreshold < 0 )
    if( aThreshold < 0 )
        aThreshold = GetPenSize() / 2;
        aThreshold = GetPenSize() / 2;


    wxPoint relpos = aPosRef - aTransform.TransformCoordinate( m_Pos );
    int dist = KiROUND( GetLineLength( aPosRef, aTransform.TransformCoordinate( m_Pos ) ) ); 

    int dist = KiROUND( EuclideanNorm( relpos ) ); 


    if( abs( dist - m_Radius ) <= aThreshold )
    if( abs( dist - m_Radius ) <= aThreshold )
        return true;
        return true;
@@ -345,9 +343,7 @@ void LIB_CIRCLE::calcEdit( const wxPoint& aPosition )
        if( m_Flags == IS_NEW )
        if( m_Flags == IS_NEW )
            SetEraseLastDrawItem();
            SetEraseLastDrawItem();


        int dx = m_Pos.x - aPosition.x;
        m_Radius = KiROUND( GetLineLength( m_Pos, aPosition ) );
        int dy = m_Pos.y - aPosition.y;
        m_Radius = KiROUND( hypot( dx, dy ) );
    }
    }
    else
    else
    {
    {
Loading