Pcbnew: make the line/arc drawing tool show segment length

This patch adds functionality to the Pcbnew draw tool to show the dx and
dy of the current segment being drawn if the relative origin (pressing
spacebar) is not already set (i.e. if those coordinates are ( 0, 0 ) ).
You can set the relative origin while using the draw tool by pressing
spacebar. The relative origin is reset on exit of the tool.

fixes: lp:1736133
* https://bugs.launchpad.net/kicad/+bug/1736133
This commit is contained in:
Robbert Lagerweij 2017-12-21 21:49:52 +01:00 committed by Wayne Stambaugh
parent 1175d50486
commit bd7f5081d1
1 changed files with 16 additions and 0 deletions

View File

@ -939,6 +939,7 @@ bool DRAWING_TOOL::drawSegment( int aShape, DRAWSEGMENT*& aGraphic,
bool direction45 = false; // 45 degrees only mode
bool started = false;
bool IsOCurseurSet = ( m_frame->GetScreen()->m_O_Curseur != wxPoint( 0, 0 ) );
VECTOR2I cursorPos = m_controls->GetCursorPosition();
if( aStartingPoint )
@ -957,6 +958,9 @@ bool DRAWING_TOOL::drawSegment( int aShape, DRAWSEGMENT*& aGraphic,
m_controls->SetAutoPan( true );
m_controls->CaptureCursor( true );
if( !IsOCurseurSet )
m_frame->GetScreen()->m_O_Curseur = wxPoint( aStartingPoint->x, aStartingPoint->y );
started = true;
}
@ -992,6 +996,8 @@ bool DRAWING_TOOL::drawSegment( int aShape, DRAWSEGMENT*& aGraphic,
m_view->Update( &preview );
delete aGraphic;
aGraphic = NULL;
if( !IsOCurseurSet )
m_frame->GetScreen()->m_O_Curseur = wxPoint( 0, 0 );
break;
}
else if( evt->IsAction( &PCB_ACTIONS::layerChanged ) )
@ -1014,6 +1020,9 @@ bool DRAWING_TOOL::drawSegment( int aShape, DRAWSEGMENT*& aGraphic,
aGraphic->SetEnd( wxPoint( cursorPos.x, cursorPos.y ) );
aGraphic->SetLayer( getDrawingLayer() );
if( !IsOCurseurSet )
m_frame->GetScreen()->m_O_Curseur = wxPoint( cursorPos.x, cursorPos.y );
if( aShape == S_SEGMENT )
line45 = *aGraphic; // used only for direction 45 mode with lines
@ -1078,8 +1087,15 @@ bool DRAWING_TOOL::drawSegment( int aShape, DRAWSEGMENT*& aGraphic,
line45.SetWidth( m_lineWidth );
m_view->Update( &preview );
}
else if( evt->IsAction( &PCB_ACTIONS::resetCoords ) )
{
IsOCurseurSet = true;
}
}
if( !IsOCurseurSet ) // reset the relative coordinte if it was not set before
m_frame->GetScreen()->m_O_Curseur = wxPoint( 0, 0 );
m_view->Remove( &preview );
m_controls->SetAutoPan( false );
m_controls->CaptureCursor( false );