From 388d74faf470692eed0e2efcd3b81a9d83cb7be4 Mon Sep 17 00:00:00 2001 From: jean-pierre charras Date: Wed, 18 Dec 2019 11:40:45 +0100 Subject: [PATCH] Pcbnew: graphic polygon: display the points count, instead of length, and coordinate origin. Previously, the meaningless length (always 0) and begin and end (@0,0) coordinates were always displayed. From master branch. --- pcbnew/class_drawsegment.cpp | 34 +++++++++++++++++++++++++++------- 1 file changed, 27 insertions(+), 7 deletions(-) diff --git a/pcbnew/class_drawsegment.cpp b/pcbnew/class_drawsegment.cpp index 9f6a905a46..ba8a23f968 100644 --- a/pcbnew/class_drawsegment.cpp +++ b/pcbnew/class_drawsegment.cpp @@ -465,6 +465,13 @@ void DRAWSEGMENT::GetMsgPanelInfo( EDA_UNITS_T aUnits, std::vector< MSG_PANEL_IT aList.push_back( MSG_PANEL_ITEM( shape, _( "Curve" ), RED ) ); break; + case S_POLYGON: + aList.emplace_back( shape, _( "Polygon" ), RED ); + + msg.Printf( "%d", GetPolyShape().Outline(0).PointCount() ); + aList.emplace_back( _( "Points" ), msg, DARKGREEN ); + break; + default: { aList.push_back( MSG_PANEL_ITEM( shape, _( "Segment" ), RED ) ); @@ -480,14 +487,27 @@ void DRAWSEGMENT::GetMsgPanelInfo( EDA_UNITS_T aUnits, std::vector< MSG_PANEL_IT } } - wxString start = wxString::Format( "@(%s, %s)", - MessageTextFromValue( aUnits, GetStart().x ), - MessageTextFromValue( aUnits, GetStart().y ) ); - wxString end = wxString::Format( "@(%s, %s)", - MessageTextFromValue( aUnits, GetEnd().x ), - MessageTextFromValue( aUnits, GetEnd().y ) ); + if( m_Shape == S_POLYGON ) + { + VECTOR2I point0 = GetPolyShape().Outline(0).CPoint(0); + wxString origin = wxString::Format( "@(%s, %s)", + MessageTextFromValue( aUnits, point0.x ), + MessageTextFromValue( aUnits, point0.y ) ); + + aList.emplace_back( _( "Origin" ), origin, DARKGREEN ); + } + else + { + wxString start = wxString::Format( "@(%s, %s)", + MessageTextFromValue( aUnits, GetStart().x ), + MessageTextFromValue( aUnits, GetStart().y ) ); + wxString end = wxString::Format( "@(%s, %s)", + MessageTextFromValue( aUnits, GetEnd().x ), + MessageTextFromValue( aUnits, GetEnd().y ) ); + + aList.emplace_back( start, end, DARKGREEN ); + } - aList.push_back( MSG_PANEL_ITEM( start, end, DARKGREEN ) ); aList.push_back( MSG_PANEL_ITEM( _( "Layer" ), GetLayerName(), DARKBROWN ) ); msg = MessageTextFromValue( aUnits, m_Width, true );