From 48823c0723c632b563f5dbee11ac902d55c4a1f6 Mon Sep 17 00:00:00 2001 From: Roberto Fernandez Bautista Date: Sun, 10 Jan 2021 13:04:21 +0000 Subject: [PATCH] Formatting fixes and fix qa_kimath following rebase --- libs/kimath/include/geometry/circle.h | 16 +++++++------- libs/kimath/include/trigo.h | 6 ++--- libs/kimath/src/geometry/circle.cpp | 4 ++-- pcbnew/tools/edit_tool.cpp | 28 ++++++++++++------------ qa/libs/kimath/geometry/test_circle.cpp | 28 +++++++++++------------- qa/libs/kimath/geometry/test_segment.cpp | 2 +- 6 files changed, 41 insertions(+), 43 deletions(-) diff --git a/libs/kimath/include/geometry/circle.h b/libs/kimath/include/geometry/circle.h index df1d2aec1f..8a7040b6f3 100644 --- a/libs/kimath/include/geometry/circle.h +++ b/libs/kimath/include/geometry/circle.h @@ -45,9 +45,9 @@ public: /** * Constructs this circle such that it is tangent to the given lines and passes through the * given point. There are two possible solutions, controlled by aAlternateSolution. - * + * * When aAlternateSolution is false, find the best solution that can be used to fillet both - * lines (i.e. choose the most likely quadrant and find the solution with smallest arc angle + * lines (i.e. choose the most likely quadrant and find the solution with smallest arc angle * between the tangent points on the lines) * * @param aLineA is the first tangent line. Treated as an infinite line except for the purpose @@ -64,11 +64,11 @@ public: /** * Function NearestPoint() * - * Computes the point on the circumference of the circle that is the closest to aP. + * Computes the point on the circumference of the circle that is the closest to aP. * * In other words: finds the intersection point of this circle and a line that passes through * both this circle's center and aP. - * + * * @param aP * @return nearest point to aP */ @@ -76,9 +76,9 @@ public: /** * Function Intersect() - * + * * Computes the intersection points between this circle and aCircle. - * + * * @param aCircle The other circle to intersect with this. * @return std::vector containing: * - 0 elements if the circles do not intersect @@ -89,9 +89,9 @@ public: /** * Function Intersect() - * + * * Computes the intersection points between this circle and aLine. - * + * * @param aLine The line to intersect with this circle (end points ignored) * @return std::vector containing: * - 0 elements if there is no intersection diff --git a/libs/kimath/include/trigo.h b/libs/kimath/include/trigo.h index 79ed7a7ce2..29b8b6eca0 100644 --- a/libs/kimath/include/trigo.h +++ b/libs/kimath/include/trigo.h @@ -120,9 +120,9 @@ double GetArcAngle( const VECTOR2I& aStart, const VECTOR2I& aMid, const VECTOR2I /** * Returns the middle point of an arc, half-way between aStart and aEnd. There are two possible - * solutions which can be found by toggling aMinArcAngle. The behaviour is undefined for + * solutions which can be found by toggling aMinArcAngle. The behaviour is undefined for * semicircles (i.e. 180 degree arcs). - * + * * @param aStart The starting point of the arc (for calculating the radius) * @param aEnd The end point of the arc (for determining the arc angle) * @param aCenter The center point of the arc @@ -130,7 +130,7 @@ double GetArcAngle( const VECTOR2I& aStart, const VECTOR2I& aMid, const VECTOR2I * @return The middle point of the arc */ const VECTOR2I GetArcMid( const VECTOR2I& aStart, const VECTOR2I& aEnd, const VECTOR2I& aCenter, - bool aMinArcAngle = true ); + bool aMinArcAngle = true ); /* Return the arc tangent of 0.1 degrees coord vector dx, dy * between -1800 and 1800 diff --git a/libs/kimath/src/geometry/circle.cpp b/libs/kimath/src/geometry/circle.cpp index 196e7d3d61..1a7988d217 100644 --- a/libs/kimath/src/geometry/circle.cpp +++ b/libs/kimath/src/geometry/circle.cpp @@ -269,7 +269,7 @@ std::vector CIRCLE::Intersect( const SEG& aLine ) const { std::vector retval; - // + // // . * . // * * // -----1-------m-------2---- @@ -287,7 +287,7 @@ std::vector CIRCLE::Intersect( const SEG& aLine ) const // to the radius. // // The distance M1 = M2 can be computed by pythagoras since O1 = O2 = Radius - // + // // O1= O2 = sqrt( Radius^2 - OM^2) // diff --git a/pcbnew/tools/edit_tool.cpp b/pcbnew/tools/edit_tool.cpp index e5e13bf68c..d7440a7b88 100644 --- a/pcbnew/tools/edit_tool.cpp +++ b/pcbnew/tools/edit_tool.cpp @@ -303,9 +303,9 @@ int EDIT_TOOL::DragArcTrack( const TOOL_EVENT& aEvent ) bool restore_state = false; VECTOR2I arcCenter = theArc->GetCenter(); - SEG tanStart = SEG( arcCenter, theArc->GetStart() ).PerpendicularSeg( theArc->GetStart() ); - SEG tanEnd = SEG( arcCenter, theArc->GetEnd() ).PerpendicularSeg( theArc->GetEnd() ); - + SEG tanStart = SEG( arcCenter, theArc->GetStart() ).PerpendicularSeg( theArc->GetStart() ); + SEG tanEnd = SEG( arcCenter, theArc->GetEnd() ).PerpendicularSeg( theArc->GetEnd() ); + if( !tanStart.ApproxParallel( tanEnd ) ) { //Ensure the tangent segments are in the correct orientation @@ -316,7 +316,7 @@ int EDIT_TOOL::DragArcTrack( const TOOL_EVENT& aEvent ) tanEnd.B = theArc->GetEnd(); } - KICAD_T track_types[] = { PCB_PAD_T, PCB_VIA_T, PCB_TRACE_T, PCB_ARC_T, EOT }; + KICAD_T track_types[] = { PCB_PAD_T, PCB_VIA_T, PCB_TRACE_T, PCB_ARC_T, EOT }; auto getUniqueConnectedTrack = [&]( const VECTOR2I& aAnchor ) -> TRACK* @@ -340,7 +340,7 @@ int EDIT_TOOL::DragArcTrack( const TOOL_EVENT& aEvent ) retval->SetFlags( IS_NEW ); getView()->Add( retval ); } - + return retval; }; @@ -348,7 +348,7 @@ int EDIT_TOOL::DragArcTrack( const TOOL_EVENT& aEvent ) TRACK* trackOnEnd = getUniqueConnectedTrack( theArc->GetEnd() ); // Make copies of items to be edited - ARC* theArcCopy = new ARC( *theArc ); + ARC* theArcCopy = new ARC( *theArc ); TRACK* trackOnStartCopy = new TRACK( *trackOnStart ); TRACK* trackOnEndCopy = new TRACK( *trackOnEnd ); @@ -365,8 +365,8 @@ int EDIT_TOOL::DragArcTrack( const TOOL_EVENT& aEvent ) } OPT_VECTOR2I optInterectTan = tanStart.IntersectLines( tanEnd ); - int tanStartSide = tanStart.Side( theArc->GetMid() ); - int tanEndSide = tanEnd.Side( theArc->GetMid() ); + int tanStartSide = tanStart.Side( theArc->GetMid() ); + int tanEndSide = tanEnd.Side( theArc->GetMid() ); bool isStartTrackOnStartPt = ( VECTOR2I( theArc->GetStart() ) - tanStart.A ).EuclideanNorm() < ( VECTOR2I( theArc->GetStart() ) - tanStart.B ).EuclideanNorm(); @@ -375,10 +375,10 @@ int EDIT_TOOL::DragArcTrack( const TOOL_EVENT& aEvent ) < ( VECTOR2I( theArc->GetStart() ) - tanEnd.B ).EuclideanNorm(); // Calculate constraints - CIRCLE maxTangentCircle; + CIRCLE maxTangentCircle; VECTOR2I startOther = ( isStartTrackOnStartPt ) ? tanStart.B : tanStart.A; maxTangentCircle.ConstructFromTanTanPt( tanStart, tanEnd, startOther ); - + VECTOR2I maxTanPtStart = tanStart.LineProject( maxTangentCircle.Center ); VECTOR2I maxTanPtEnd = tanEnd.LineProject( maxTangentCircle.Center ); @@ -478,7 +478,7 @@ int EDIT_TOOL::DragArcTrack( const TOOL_EVENT& aEvent ) CIRCLE circlehelper; circlehelper.ConstructFromTanTanPt( tanStart, tanEnd, m_cursor ); - VECTOR2I newCenter = circlehelper.Center; + VECTOR2I newCenter = circlehelper.Center; VECTOR2I newStart = tanStart.LineProject( newCenter ); VECTOR2I newEnd = tanEnd.LineProject( newCenter ); VECTOR2I newMid = GetArcMid( newStart, newEnd, newCenter ); @@ -497,7 +497,7 @@ int EDIT_TOOL::DragArcTrack( const TOOL_EVENT& aEvent ) trackOnEnd->SetStart( (wxPoint) newEnd ); else trackOnEnd->SetEnd( (wxPoint) newEnd ); - + //Update view getView()->Update( trackOnStart ); getView()->Update( trackOnEnd ); @@ -522,8 +522,8 @@ int EDIT_TOOL::DragArcTrack( const TOOL_EVENT& aEvent ) } // Ensure we only do one commit operation on each object - auto processTrack = - [&]( TRACK* aTrack, TRACK* aTrackCopy ) + auto processTrack = + [&]( TRACK* aTrack, TRACK* aTrackCopy ) { if( aTrack->IsNew() ) { diff --git a/qa/libs/kimath/geometry/test_circle.cpp b/qa/libs/kimath/geometry/test_circle.cpp index 99bb5edd77..bdff759dbb 100644 --- a/qa/libs/kimath/geometry/test_circle.cpp +++ b/qa/libs/kimath/geometry/test_circle.cpp @@ -142,14 +142,14 @@ struct CIR_CIR_VECPT_CASE // clang-format off /** - * Test cases for #CIRCLE::Intersect( const CIRCLE& aCircle ) + * Test cases for #CIRCLE::Intersect( const CIRCLE& aCircle ) */ static const std::vector intersect_circle_cases = { { "two point aligned", { { 10, 10 }, 20 }, { { 10, 45 }, 20 }, - { + { { 0, 27 }, { 21, 27 }, }, @@ -158,7 +158,7 @@ static const std::vector intersect_circle_cases = { "two point angled", { { 10, 10 }, 20 }, { { 20, 20 }, 20 }, - { + { { 2, 28 }, { 28, 2 }, }, @@ -167,7 +167,7 @@ static const std::vector intersect_circle_cases = { "tangent aligned", { { 10, 10 }, 20 }, { { 10, 50 }, 20 }, - { + { { 10, 30 }, }, }, @@ -175,7 +175,7 @@ static const std::vector intersect_circle_cases = { "no intersection", { { 10, 10 }, 20 }, { { 10, 51 }, 20 }, - { + { //no points }, }, @@ -218,14 +218,14 @@ struct SEG_SEG_VECPT_CASE // clang-format off /** - * Test cases for #CIRCLE::Intersect( const SEG& aSeg ) + * Test cases for #CIRCLE::Intersect( const SEG& aSeg ) */ static const std::vector intersect_line_cases = { { "two point aligned", { { 0, 0 }, 20 }, { { 10, 45 }, {10, 40} }, - { + { { 10, -17 }, { 10, 17 }, }, @@ -234,7 +234,7 @@ static const std::vector intersect_line_cases = { "two point angled", { { 0, 0 }, 20 }, { { -20, -40 }, {20, 40} }, - { + { { 8, 17 }, { -8, -17 }, }, @@ -243,7 +243,7 @@ static const std::vector intersect_line_cases = { "tangent", { { 0, 0 }, 20 }, { { 20, 0 }, {20, 40} }, - { + { { 20, 0 } }, }, @@ -251,7 +251,7 @@ static const std::vector intersect_line_cases = { "no intersection", { { 0, 0 }, 20 }, { { 25, 0 }, {25, 40} }, - { + { //no points }, }, @@ -286,7 +286,7 @@ struct CIR_SEG_VECPT_CASE // clang-format off /** - * Test cases for #CIRCLE::Intersect( const SEG& aSeg ) + * Test cases for #CIRCLE::Intersect( const SEG& aSeg ) */ static const std::vector construct_tan_tan_pt_cases = { { @@ -301,8 +301,7 @@ static const std::vector construct_tan_tan_pt_cases = { { { 0, 0 }, { 0, 1000 } }, { { 0, 0 }, { 1000, 0 } }, { 200, 100 }, - { { 490, 490} , 490 }, // ammended to get the test to pass - //{ { 500, 500} , 500 }, // result from LibreCAD 2.2.0-rc2 + { { 500, 500} , 500 }, // result from LibreCAD 2.2.0-rc2 }, { "45 degree segs, point on seg", @@ -316,8 +315,7 @@ static const std::vector construct_tan_tan_pt_cases = { { { 0, 0 }, { 1000000, 0 } }, { { 0, 0 }, { 1000000, 1000000 } }, { 200000, 100000 }, - { { 332434, 137698} , 137698 }, // ammended to get the test to pass - //{ { 332439, 137701} , 137701 }, // result from LibreCAD 2.2.0-rc2 + { { 332439, 137701} , 137701 }, // result from LibreCAD 2.2.0-rc2 }, { "135 degree segs, point on seg", diff --git a/qa/libs/kimath/geometry/test_segment.cpp b/qa/libs/kimath/geometry/test_segment.cpp index 98515f1067..f69cd77a78 100644 --- a/qa/libs/kimath/geometry/test_segment.cpp +++ b/qa/libs/kimath/geometry/test_segment.cpp @@ -690,7 +690,7 @@ BOOST_AUTO_TEST_CASE( SegCreatePerpendicular ) { SEG perpendicular = c.m_seg.PerpendicularSeg( c.m_vec ); - BOOST_CHECK_PREDICATE( SegPerpendicularCorrect, ( perpendicular )( c.m_seg )( true ) ); + BOOST_CHECK_PREDICATE( SegPerpendicularCorrect, ( perpendicular )( c.m_seg )( true ) ); BOOST_CHECK_PREDICATE( SegVecDistanceCorrect, ( perpendicular )( c.m_vec )( 0 ) ); } }