diff --git a/3d-viewer/3d_rendering/3d_render_ogl_legacy/c3d_render_ogl_legacy.cpp b/3d-viewer/3d_rendering/3d_render_ogl_legacy/c3d_render_ogl_legacy.cpp index edba9bbc5f..c94d884ce4 100644 --- a/3d-viewer/3d_rendering/3d_render_ogl_legacy/c3d_render_ogl_legacy.cpp +++ b/3d-viewer/3d_rendering/3d_render_ogl_legacy/c3d_render_ogl_legacy.cpp @@ -1428,8 +1428,8 @@ void C3D_RENDER_OGL_LEGACY::generate_new_3DGrid( GRID3D_TYPE aGridType ) // Color of grid lines every 5 lines const SFVEC3F gridColor_marker = m_boardAdapter.GetColor( LIGHTGRAY ); - const double scale = m_boardAdapter.BiuTo3Dunits(); - const double transparency = 0.35; + const double scale = m_boardAdapter.BiuTo3Dunits(); + const GLfloat transparency = 0.35f; double griSizeMM = 0.0; diff --git a/3d-viewer/3d_rendering/ccamera.cpp b/3d-viewer/3d_rendering/ccamera.cpp index 6cc779c200..c0d437e757 100644 --- a/3d-viewer/3d_rendering/ccamera.cpp +++ b/3d-viewer/3d_rendering/ccamera.cpp @@ -35,10 +35,10 @@ inline void normalise2PI( float& aAngle ) { while( aAngle > 0.0 ) - aAngle -= M_PI*2; + aAngle -= static_cast( M_PI * 2.0f ); while( aAngle < 0.0 ) - aAngle += M_PI*2; + aAngle += static_cast( M_PI * 2.0f ); } @@ -112,14 +112,13 @@ void CCAMERA::Reset_T1() // one to where we currently are. That ensures that we rotate // the board around the smallest distance getting there. if( m_rotate_aux_t0.x > M_PI ) - m_rotate_aux_t1.x = 2*M_PI; + m_rotate_aux_t1.x = static_cast( 2.0f * M_PI ); if( m_rotate_aux_t0.y > M_PI ) - m_rotate_aux_t1.y = 2*M_PI; + m_rotate_aux_t1.y = static_cast( 2.0f * M_PI ); if( m_rotate_aux_t0.z > M_PI ) - m_rotate_aux_t1.z = 2*M_PI; - + m_rotate_aux_t1.z = static_cast( 2.0f * M_PI ); } diff --git a/common/base_struct.cpp b/common/base_struct.cpp index 4d202d20e8..147c7cc223 100644 --- a/common/base_struct.cpp +++ b/common/base_struct.cpp @@ -546,10 +546,10 @@ bool EDA_RECT::IntersectsCircle( const wxPoint& aCenter, const int aRadius ) con wxPoint closest = ClosestPointTo( aCenter ); - double dx = aCenter.x - closest.x; - double dy = aCenter.y - closest.y; + double dx = static_cast( aCenter.x ) - closest.x; + double dy = static_cast( aCenter.y ) - closest.y; - double r = (double) aRadius; + double r = static_cast( aRadius ); return ( dx * dx + dy * dy ) <= ( r * r ); } diff --git a/common/origin_transforms.cpp b/common/origin_transforms.cpp index 9faa4eebdf..4972312353 100644 --- a/common/origin_transforms.cpp +++ b/common/origin_transforms.cpp @@ -35,7 +35,7 @@ ORIGIN_TRANSFORMS::~ORIGIN_TRANSFORMS() int ORIGIN_TRANSFORMS::ToDisplay( int aValue, COORD_TYPES_T aCoordType ) { - return ToDisplay( static_cast(aValue), aCoordType ); + return static_cast( ToDisplay( static_cast( aValue ), aCoordType ) ); } long long int ORIGIN_TRANSFORMS::ToDisplay( long long int aValue, @@ -53,7 +53,7 @@ double ORIGIN_TRANSFORMS::ToDisplay( double aValue, int ORIGIN_TRANSFORMS::FromDisplay( int aValue, COORD_TYPES_T aCoordType ) { - return FromDisplay( static_cast(aValue), aCoordType ); + return static_cast( FromDisplay( static_cast( aValue ), aCoordType ) ); } long long int ORIGIN_TRANSFORMS::FromDisplay( long long int aValue, diff --git a/eeschema/sch_eagle_plugin.h b/eeschema/sch_eagle_plugin.h index c9f8916042..1f1be2ef1d 100644 --- a/eeschema/sch_eagle_plugin.h +++ b/eeschema/sch_eagle_plugin.h @@ -204,7 +204,7 @@ private: std::vector m_wireIntersections; ///> Wires and labels of a single connection (segment in Eagle nomenclature) - typedef struct { + typedef struct SEG_DESC_STRUCT { ///> Tests if a particular label is attached to any of the stored segments const SEG* LabelAttached( const SCH_TEXT* aLabel ) const; diff --git a/include/layers_id_colors_and_visibility.h b/include/layers_id_colors_and_visibility.h index e719cc9eb1..07e893c927 100644 --- a/include/layers_id_colors_and_visibility.h +++ b/include/layers_id_colors_and_visibility.h @@ -293,13 +293,13 @@ public: GAL_SET& set( GAL_LAYER_ID aPos, bool aVal = true ) { - GAL_BASE_SET::set( static_cast( aPos ) - start, aVal ); + GAL_BASE_SET::set( static_cast( aPos ) - start, aVal ); return *this; } bool Contains( GAL_LAYER_ID aPos ) { - return test( static_cast( aPos ) - start ); + return test( static_cast( aPos ) - start ); } std::vector Seq() const; diff --git a/libs/kimath/include/geometry/seg.h b/libs/kimath/include/geometry/seg.h index 75287c4152..b39a236b99 100644 --- a/libs/kimath/include/geometry/seg.h +++ b/libs/kimath/include/geometry/seg.h @@ -228,8 +228,8 @@ public: void CanonicalCoefs( ecoord& qA, ecoord& qB, ecoord& qC ) const { - qA = A.y - B.y; - qB = B.x - A.x; + qA = ecoord{ A.y } - B.y; + qB = ecoord{ B.x } - A.x; qC = -qA * A.x - qB * A.y; } @@ -369,16 +369,16 @@ inline VECTOR2I SEG::LineProject( const VECTOR2I& aP ) const ecoord t = d.Dot( aP - A ); - int xp = rescale( t, (ecoord)d.x, l_squared ); - int yp = rescale( t, (ecoord)d.y, l_squared ); + int xp = rescale( t, ecoord{ d.x }, l_squared ); + int yp = rescale( t, ecoord{ d.y }, l_squared ); return A + VECTOR2I( xp, yp ); } inline int SEG::LineDistance( const VECTOR2I& aP, bool aDetermineSide ) const { - ecoord p = A.y - B.y; - ecoord q = B.x - A.x; + ecoord p = ecoord{ A.y } - B.y; + ecoord q = ecoord{ B.x } - A.x; ecoord r = -p * A.x - q * A.y; ecoord dist = ( p * aP.x + q * aP.y + r ) / sqrt( p * p + q * q ); diff --git a/libs/kimath/include/geometry/shape_arc.h b/libs/kimath/include/geometry/shape_arc.h index ca0001786d..b4eb41b46f 100644 --- a/libs/kimath/include/geometry/shape_arc.h +++ b/libs/kimath/include/geometry/shape_arc.h @@ -132,8 +132,8 @@ private: bool ccw( const VECTOR2I& aA, const VECTOR2I& aB, const VECTOR2I& aC ) const { - return (ecoord) ( aC.y - aA.y ) * ( aB.x - aA.x ) > - (ecoord) ( aB.y - aA.y ) * ( aC.x - aA.x ); + return ( ecoord{ aC.y } - aA.y ) * ( ecoord{ aB.x } - aA.x ) > + ( ecoord{ aB.y } - aA.y ) * ( ecoord{ aC.x } - aA.x ); } void update_bbox(); diff --git a/libs/kimath/include/trigo.h b/libs/kimath/include/trigo.h index 5fc37c5050..f443abfdba 100644 --- a/libs/kimath/include/trigo.h +++ b/libs/kimath/include/trigo.h @@ -156,10 +156,10 @@ inline double DistanceLinePoint( const wxPoint &linePointA, // the division (EuclideanNorm gives a double so from int it would // be promoted); that means that the whole expression were // vulnerable to overflow during int multiplications - return fabs( ( double(linePointB.x - linePointA.x) * - double(linePointA.y - referencePoint.y) - - double(linePointA.x - referencePoint.x ) * - double(linePointB.y - linePointA.y) ) + return fabs( ( static_cast( linePointB.x - linePointA.x ) * + static_cast( linePointA.y - referencePoint.y ) - + static_cast( linePointA.x - referencePoint.x ) * + static_cast( linePointB.y - linePointA.y) ) / EuclideanNorm( linePointB - linePointA ) ); } diff --git a/libs/kimath/src/trigo.cpp b/libs/kimath/src/trigo.cpp index 5e93e0718f..135faf2a00 100644 --- a/libs/kimath/src/trigo.cpp +++ b/libs/kimath/src/trigo.cpp @@ -66,8 +66,8 @@ bool SegmentIntersectsSegment( const wxPoint &a_p1_l1, const wxPoint &a_p2_l1, //We are forced to use 64bit ints because the internal units can overflow 32bit ints when // multiplied with each other, the alternative would be to scale the units down (i.e. divide // by a fixed number). - long long dX_a, dY_a, dX_b, dY_b, dX_ab, dY_ab; - long long num_a, num_b, den; + int64_t dX_a, dY_a, dX_b, dY_b, dX_ab, dY_ab; + int64_t num_a, num_b, den; //Test for intersection within the bounds of both line segments using line equations of the // form: @@ -75,12 +75,12 @@ bool SegmentIntersectsSegment( const wxPoint &a_p1_l1, const wxPoint &a_p2_l1, // y_k(u_k) = u_k * dY_k + y_k(0) // with 0 <= u_k <= 1 and k = [ a, b ] - dX_a = a_p2_l1.x - a_p1_l1.x; - dY_a = a_p2_l1.y - a_p1_l1.y; - dX_b = a_p2_l2.x - a_p1_l2.x; - dY_b = a_p2_l2.y - a_p1_l2.y; - dX_ab = a_p1_l2.x - a_p1_l1.x; - dY_ab = a_p1_l2.y - a_p1_l1.y; + dX_a = int64_t{ a_p2_l1.x } - a_p1_l1.x; + dY_a = int64_t{ a_p2_l1.y } - a_p1_l1.y; + dX_b = int64_t{ a_p2_l2.x } - a_p1_l2.x; + dY_b = int64_t{ a_p2_l2.y } - a_p1_l2.y; + dX_ab = int64_t{ a_p1_l2.x } - a_p1_l1.x; + dY_ab = int64_t{ a_p1_l2.y } - a_p1_l1.y; den = dY_a * dX_b - dY_b * dX_a ; diff --git a/pcbnew/autorouter/rect_placement/rect_placement.cpp b/pcbnew/autorouter/rect_placement/rect_placement.cpp index f4acb4e934..bbae48bcff 100644 --- a/pcbnew/autorouter/rect_placement/rect_placement.cpp +++ b/pcbnew/autorouter/rect_placement/rect_placement.cpp @@ -190,7 +190,7 @@ bool CRectPlacement::AddAtEmptySpotAutoGrow( TRect* pRect, int maxW, int maxH ) { double growing_factor = 1.2; // Must be > 1.0, and event > 1.1 for fast optimization - #define GROW(x) ((x * growing_factor) + 1) + #define GROW(x) static_cast( (x * growing_factor) + 1 ) if( pRect->w <= 0 ) return true; diff --git a/pcbnew/class_module.cpp b/pcbnew/class_module.cpp index 5dfe23f923..d9f11c430e 100644 --- a/pcbnew/class_module.cpp +++ b/pcbnew/class_module.cpp @@ -558,8 +558,8 @@ void MODULE::CalculateBoundingBox() double MODULE::GetArea( int aPadding ) const { - double w = std::abs( m_BoundaryBox.GetWidth() ) + aPadding; - double h = std::abs( m_BoundaryBox.GetHeight() ) + aPadding; + double w = std::abs( static_cast( m_BoundaryBox.GetWidth() ) ) + aPadding; + double h = std::abs( static_cast( m_BoundaryBox.GetHeight() ) ) + aPadding; return w * h; } diff --git a/pcbnew/io_mgr.h b/pcbnew/io_mgr.h index 239b26bba5..a872cee0f5 100644 --- a/pcbnew/io_mgr.h +++ b/pcbnew/io_mgr.h @@ -585,10 +585,10 @@ public: RELEASER& operator=( RELEASER& aOther ) { return *this; } // private copy constructor so it's illegal - RELEASER( const RELEASER& aOther ) {} + RELEASER( const RELEASER& aOther ) : plugin( nullptr ) {} public: - RELEASER( PLUGIN* aPlugin = NULL ) : + RELEASER( PLUGIN* aPlugin = nullptr ) : plugin( aPlugin ) { } @@ -602,7 +602,7 @@ public: void release() { IO_MGR::PluginRelease( plugin ); - plugin = NULL; + plugin = nullptr; } void set( PLUGIN* aPlugin ) diff --git a/pcbnew/pcb_parser.cpp b/pcbnew/pcb_parser.cpp index ef4a496d76..58db2a486a 100644 --- a/pcbnew/pcb_parser.cpp +++ b/pcbnew/pcb_parser.cpp @@ -130,7 +130,7 @@ void PCB_PARSER::pushValueIntoMap( int aIndex, int aValue ) // ensure there is room in m_netCodes for that, and add room if needed. if( (int)m_netCodes.size() <= aIndex ) - m_netCodes.resize( aIndex+1 ); + m_netCodes.resize( static_cast( aIndex ) + 1 ); m_netCodes[aIndex] = aValue; } diff --git a/pcbnew/router/pns_optimizer.cpp b/pcbnew/router/pns_optimizer.cpp index b31994cfa5..8ab03483d1 100644 --- a/pcbnew/router/pns_optimizer.cpp +++ b/pcbnew/router/pns_optimizer.cpp @@ -353,8 +353,10 @@ static bool pointInside2( const SHAPE_LINE_CHAIN& aL, const VECTOR2I& aP ) result = 1 - result; else { - double d = (double) (ip.x -aP.x) * (ipNext.y -aP.y) - - (double) (ipNext.x -aP.x) * (ip.y -aP.y); + double d = static_cast( ip.x - aP.x ) * + static_cast( ipNext.y - aP.y ) - + static_cast( ipNext.x - aP.x ) * + static_cast( ip.y - aP.y ); if( !d ) return -1; @@ -367,8 +369,8 @@ static bool pointInside2( const SHAPE_LINE_CHAIN& aL, const VECTOR2I& aP ) { if( ipNext.x >aP.x ) { - double d = (double) (ip.x -aP.x) * (ipNext.y -aP.y) - - (double) (ipNext.x -aP.x) * (ip.y -aP.y); + double d = ((double)ip.x -aP.x) * ((double)ipNext.y -aP.y) - + ((double)ipNext.x -aP.x) * ((double)ip.y -aP.y); if( !d ) return -1; @@ -635,7 +637,7 @@ bool OPTIMIZER::mergeStep( LINE* aLine, SHAPE_LINE_CHAIN& aCurrentPath, int step for( int n = 0; n < n_segs - step; n++ ) { // Do not attempt to merge false segments that are part of an arc - if( aCurrentPath.isArc( n ) || aCurrentPath.isArc( n + step ) ) + if( aCurrentPath.isArc( n ) || aCurrentPath.isArc( static_cast( n ) + step ) ) continue; const SEG s1 = aCurrentPath.CSegment( n ); @@ -1089,7 +1091,7 @@ int findCoupledVertices( const VECTOR2I& aVertex, const SEG& aOrigSeg, const SHA if( s.ApproxParallel ( aOrigSeg ) ) { - int64_t dist = ( projOverCoupled - aVertex ).EuclideanNorm() - aPair->Width(); + int64_t dist = int64_t{(( projOverCoupled - aVertex ).EuclideanNorm())} - aPair->Width(); if( aPair->GapConstraint().Matches( dist ) ) { diff --git a/plugins/3d/oce/loadmodel.cpp b/plugins/3d/oce/loadmodel.cpp index f295726c39..30bbd83a2a 100644 --- a/plugins/3d/oce/loadmodel.cpp +++ b/plugins/3d/oce/loadmodel.cpp @@ -231,10 +231,10 @@ struct DATA return defaultColor; IFSG_APPEARANCE app( true ); - app.SetShininess( 0.05 ); - app.SetSpecular( 0.04, 0.04, 0.04 ); - app.SetAmbient( 0.1, 0.1, 0.1 ); - app.SetDiffuse( 0.6,0.6, 0.6 ); + app.SetShininess( 0.05f ); + app.SetSpecular( 0.04f, 0.04f, 0.04f ); + app.SetAmbient( 0.1f, 0.1f, 0.1f ); + app.SetDiffuse( 0.6f, 0.6f, 0.6f ); defaultColor = app.GetRawPtr(); return defaultColor; @@ -248,9 +248,9 @@ struct DATA return item->second; IFSG_APPEARANCE app( true ); - app.SetShininess( 0.1 ); - app.SetSpecular( 0.12, 0.12, 0.12 ); - app.SetAmbient( 0.1, 0.1, 0.1 ); + app.SetShininess( 0.1f ); + app.SetSpecular( 0.12f, 0.12f, 0.12f ); + app.SetAmbient( 0.1f, 0.1f, 0.1f ); app.SetDiffuse( colorObj->Red(), colorObj->Green(), colorObj->Blue() ); colors.insert( std::pair< Standard_Real, SGNODE* >( id, app.GetRawPtr() ) ); diff --git a/plugins/3d/vrml/wrlfacet.cpp b/plugins/3d/vrml/wrlfacet.cpp index b5cb61aae9..2864ad8040 100644 --- a/plugins/3d/vrml/wrlfacet.cpp +++ b/plugins/3d/vrml/wrlfacet.cpp @@ -40,23 +40,23 @@ static bool VDegenerate( glm::vec3* pts ) double dx, dy, dz; - dx = pts[1].x - pts[0].x; - dy = pts[1].y - pts[0].y; - dz = pts[1].z - pts[0].z; + dx = double{ pts[1].x } - pts[0].x; + dy = double{ pts[1].y } - pts[0].y; + dz = double{ pts[1].z } - pts[0].z; if( ( dx*dx + dy*dy + dz*dz ) < LOWER_LIMIT ) return true; - dx = pts[2].x - pts[0].x; - dy = pts[2].y - pts[0].y; - dz = pts[2].z - pts[0].z; + dx = double{ pts[2].x } - pts[0].x; + dy = double{ pts[2].y } - pts[0].y; + dz = double{ pts[2].z } - pts[0].z; if( ( dx*dx + dy*dy + dz*dz ) < LOWER_LIMIT ) return true; - dx = pts[2].x - pts[1].x; - dy = pts[2].y - pts[1].y; - dz = pts[2].z - pts[1].z; + dx = double{ pts[2].x } - pts[1].x; + dy = double{ pts[2].y } - pts[1].y; + dz = double{ pts[2].z } - pts[1].z; if( ( dx*dx + dy*dy + dz*dz ) < LOWER_LIMIT ) return true; @@ -118,28 +118,28 @@ static float VCalcCosAngle( const WRLVEC3F& p1, const WRLVEC3F& p2, const WRLVEC float p13 = dx*dx + dy*dy + dz*dz; l13 = sqrtf( p13 ); - float dn = 2.0 * l12 * l13; + float dn = 2.0f * l12 * l13; // place a limit to prevent calculations from blowing up if( dn < LOWER_LIMIT ) { if( (p12 + p13 - p23) < FLT_EPSILON ) - return -1.0; + return -1.0f; if( (p12 + p13 - p23) > FLT_EPSILON ) - return 1.0; + return 1.0f; - return 0.0; + return 0.0f; } float cosAngle = (p12 + p13 - p23) / dn; // check the domain; errors in the cosAngle calculation // can result in domain errors - if( cosAngle > 1.0 ) - cosAngle = 1.0; - else if( cosAngle < -1.0 ) - cosAngle = -1.0; + if( cosAngle > 1.0f ) + cosAngle = 1.0f; + else if( cosAngle < -1.0f ) + cosAngle = -1.0f; // note: we are guaranteed that acosf() is never negative return cosAngle; @@ -653,7 +653,7 @@ void FACET::CollectVertices( std::vector< std::list< FACET* > >& aFacetList ) // note: in principle this should never be invoked if( (maxIdx + 1) >= (int)aFacetList.size() ) - aFacetList.resize( maxIdx + 1 ); + aFacetList.resize( static_cast( maxIdx ) + 1 ); std::vector< int >::iterator sI = indices.begin(); std::vector< int >::iterator eI = indices.end(); @@ -729,8 +729,8 @@ SGNODE* SHAPE::CalcShape( SGNODE* aParent, SGNODE* aColor, WRL1_ORDER aVertexOrd while( sF != eF ) { - tV = (*sF)->CalcFaceNormal(); - tmi = (*sF)->GetMaxIndex(); + tV = ( *sF )->CalcFaceNormal(); + tmi = ( *sF )->GetMaxIndex(); if( tmi > maxIdx ) maxIdx = tmi; @@ -753,8 +753,8 @@ SGNODE* SHAPE::CalcShape( SGNODE* aParent, SGNODE* aColor, WRL1_ORDER aVertexOrd while( sF != eF ) { - (*sF)->Renormalize( tV ); - (*sF)->CollectVertices( flist ); + ( *sF )->Renormalize( tV ); + ( *sF )->CollectVertices( flist ); ++sF; } @@ -768,7 +768,7 @@ SGNODE* SHAPE::CalcShape( SGNODE* aParent, SGNODE* aColor, WRL1_ORDER aVertexOrd while( sF != eF ) { - (*sF)->CalcVertexNormal( i, flist[i], aCreaseLimit ); + ( *sF )->CalcVertexNormal( static_cast( i ), flist[i], aCreaseLimit ); ++sF; } } @@ -783,7 +783,7 @@ SGNODE* SHAPE::CalcShape( SGNODE* aParent, SGNODE* aColor, WRL1_ORDER aVertexOrd while( sF != eF ) { - (*sF)->GetData( vertices, normals, colors, aVertexOrder ); + ( *sF )->GetData( vertices, normals, colors, aVertexOrder ); ++sF; }