From 435ca8a7ddb8ea0eeb17bb4b877e9ce8921a4cc3 Mon Sep 17 00:00:00 2001 From: Tomasz Wlostowski Date: Thu, 5 Mar 2015 10:02:29 +0100 Subject: [PATCH] router: fix tuning status popup & incorrect length display --- pcbnew/router/length_tuner_tool.cpp | 33 ++++++++++++++--------- pcbnew/router/length_tuner_tool.h | 3 +++ pcbnew/router/pns_meander_placer_base.cpp | 16 ++++++++++- 3 files changed, 39 insertions(+), 13 deletions(-) diff --git a/pcbnew/router/length_tuner_tool.cpp b/pcbnew/router/length_tuner_tool.cpp index 51e36abe2f..792f514429 100644 --- a/pcbnew/router/length_tuner_tool.cpp +++ b/pcbnew/router/length_tuner_tool.cpp @@ -147,6 +147,16 @@ void LENGTH_TUNER_TOOL::handleCommonEvents( const TOOL_EVENT& aEvent ) } } +void LENGTH_TUNER_TOOL::updateStatusPopup( PNS_TUNE_STATUS_POPUP& aPopup ) +{ + wxPoint p = wxGetMousePosition(); + + p.x += 20; + p.y += 20; + + aPopup.Update( m_router ); + aPopup.Move( p ); +} void LENGTH_TUNER_TOOL::performTuning() { @@ -170,14 +180,19 @@ void LENGTH_TUNER_TOOL::performTuning() return; } + PNS_MEANDER_PLACER_BASE* placer = static_cast( m_router->Placer() ); + + placer->UpdateSettings( m_savedMeanderSettings ); + + VECTOR2I end( m_startSnapPoint ); + PNS_TUNE_STATUS_POPUP statusPopup( m_frame ); statusPopup.Popup(); - PNS_MEANDER_PLACER* placer = static_cast( m_router->Placer() ); - VECTOR2I end; - - placer->UpdateSettings( m_savedMeanderSettings ); + m_router->Move( end, NULL ); + updateStatusPopup( statusPopup ); + while( OPT_TOOL_EVENT evt = Wait() ) { if( evt->IsCancel() || evt->IsActivate() ) @@ -191,14 +206,8 @@ void LENGTH_TUNER_TOOL::performTuning() { end = evt->Position(); m_router->Move( end, NULL ); - - wxPoint p = wxGetMousePosition(); - - p.x += 20; - p.y += 20; - - statusPopup.Update( m_router ); - statusPopup.Move( p ); + updateStatusPopup( statusPopup ); + } else if( evt->IsClick( BUT_LEFT ) ) { diff --git a/pcbnew/router/length_tuner_tool.h b/pcbnew/router/length_tuner_tool.h index ed6ebf8fc1..075d907b39 100644 --- a/pcbnew/router/length_tuner_tool.h +++ b/pcbnew/router/length_tuner_tool.h @@ -44,6 +44,9 @@ private: void performTuning( ); int mainLoop( PNS_ROUTER_MODE aMode ); void handleCommonEvents( const TOOL_EVENT& aEvent ); + void updateStatusPopup ( PNS_TUNE_STATUS_POPUP& aPopup ); + + PNS_MEANDER_SETTINGS m_savedMeanderSettings; }; diff --git a/pcbnew/router/pns_meander_placer_base.cpp b/pcbnew/router/pns_meander_placer_base.cpp index 291a33a763..a8b04b285b 100644 --- a/pcbnew/router/pns_meander_placer_base.cpp +++ b/pcbnew/router/pns_meander_placer_base.cpp @@ -64,7 +64,20 @@ void PNS_MEANDER_PLACER_BASE::cutTunedLine( const SHAPE_LINE_CHAIN& aOrigin, SHAPE_LINE_CHAIN& aTuned, SHAPE_LINE_CHAIN& aPost ) { - VECTOR2I n = aOrigin.NearestPoint( aCursorPos ); + VECTOR2I cp ( aCursorPos ); + + if ( cp == aTuneStart ) // we don't like tuning segments with 0 length + { + int idx = aOrigin.FindSegment( cp ); + if( idx >= 0 ) + { + const SEG& s = aOrigin.CSegment( idx ); + cp += (s.B - s.A).Resize(2); + } else + cp += VECTOR2I (2, 5); // some arbitrary value that is not 45 degrees oriented + } + + VECTOR2I n = aOrigin.NearestPoint( cp ); VECTOR2I m = aOrigin.NearestPoint( aTuneStart ); SHAPE_LINE_CHAIN l( aOrigin ); @@ -84,6 +97,7 @@ void PNS_MEANDER_PLACER_BASE::cutTunedLine( const SHAPE_LINE_CHAIN& aOrigin, aPre = l.Slice( 0, i_start ); aPost = l.Slice( i_end, -1 ); aTuned = l.Slice( i_start, i_end ); + aTuned.Simplify(); }