pcbnew: Drawing tool's crosshairs follow the element
When drawing the crosshair should track the element while the mouse provides the position to calculate the next snap. Fixes: lp:1796524 * https://bugs.launchpad.net/kicad/+bug/1796524
This commit is contained in:
parent
85194989b2
commit
821b10a37e
|
@ -524,7 +524,8 @@ int DRAWING_TOOL::DrawDimension( const TOOL_EVENT& aEvent )
|
||||||
{
|
{
|
||||||
grid.SetSnap( !evt->Modifier( MD_SHIFT ) );
|
grid.SetSnap( !evt->Modifier( MD_SHIFT ) );
|
||||||
grid.SetUseGrid( !evt->Modifier( MD_ALT ) );
|
grid.SetUseGrid( !evt->Modifier( MD_ALT ) );
|
||||||
VECTOR2I cursorPos = grid.BestSnapAnchor( m_controls->GetCursorPosition(), nullptr );
|
m_controls->SetSnapping( !evt->Modifier( MD_ALT ) );
|
||||||
|
VECTOR2I cursorPos = grid.BestSnapAnchor( m_controls->GetMousePosition(), nullptr );
|
||||||
|
|
||||||
|
|
||||||
if( TOOL_EVT_UTILS::IsCancelInteractive( *evt ) )
|
if( TOOL_EVT_UTILS::IsCancelInteractive( *evt ) )
|
||||||
|
@ -989,14 +990,13 @@ bool DRAWING_TOOL::drawSegment( int aShape, DRAWSEGMENT*& aGraphic,
|
||||||
|
|
||||||
m_toolMgr->RunAction( PCB_ACTIONS::selectionClear, true );
|
m_toolMgr->RunAction( PCB_ACTIONS::selectionClear, true );
|
||||||
m_controls->ShowCursor( true );
|
m_controls->ShowCursor( true );
|
||||||
m_controls->SetSnapping( false );
|
|
||||||
|
|
||||||
Activate();
|
Activate();
|
||||||
|
|
||||||
bool direction45 = false; // 45 degrees only mode
|
bool direction45 = false; // 45 degrees only mode
|
||||||
bool started = false;
|
bool started = false;
|
||||||
bool IsOCurseurSet = ( m_frame->GetScreen()->m_O_Curseur != wxPoint( 0, 0 ) );
|
bool IsOCurseurSet = ( m_frame->GetScreen()->m_O_Curseur != wxPoint( 0, 0 ) );
|
||||||
VECTOR2I cursorPos = m_controls->GetCursorPosition();
|
VECTOR2I cursorPos = m_controls->GetMousePosition();
|
||||||
|
|
||||||
if( aStartingPoint )
|
if( aStartingPoint )
|
||||||
{
|
{
|
||||||
|
@ -1027,7 +1027,8 @@ bool DRAWING_TOOL::drawSegment( int aShape, DRAWSEGMENT*& aGraphic,
|
||||||
{
|
{
|
||||||
grid.SetSnap( !evt->Modifier( MD_SHIFT ) );
|
grid.SetSnap( !evt->Modifier( MD_SHIFT ) );
|
||||||
grid.SetUseGrid( !evt->Modifier( MD_ALT ) );
|
grid.SetUseGrid( !evt->Modifier( MD_ALT ) );
|
||||||
cursorPos = grid.BestSnapAnchor( m_controls->GetCursorPosition(), getDrawingLayer() );
|
m_controls->SetSnapping( !evt->Modifier( MD_ALT ) );
|
||||||
|
cursorPos = grid.BestSnapAnchor( m_controls->GetMousePosition(), getDrawingLayer() );
|
||||||
|
|
||||||
// 45 degree angle constraint enabled with an option and toggled with Ctrl
|
// 45 degree angle constraint enabled with an option and toggled with Ctrl
|
||||||
const bool limit45 = ( frame()->Settings().m_use45DegreeGraphicSegments != !!( evt->Modifier( MD_CTRL ) ) );
|
const bool limit45 = ( frame()->Settings().m_use45DegreeGraphicSegments != !!( evt->Modifier( MD_CTRL ) ) );
|
||||||
|
@ -1211,7 +1212,7 @@ bool DRAWING_TOOL::drawArc( DRAWSEGMENT*& aGraphic )
|
||||||
GRID_HELPER grid( m_frame );
|
GRID_HELPER grid( m_frame );
|
||||||
|
|
||||||
m_controls->ShowCursor( true );
|
m_controls->ShowCursor( true );
|
||||||
m_controls->SetSnapping( false );
|
m_controls->SetSnapping( true );
|
||||||
|
|
||||||
Activate();
|
Activate();
|
||||||
|
|
||||||
|
@ -1225,7 +1226,8 @@ bool DRAWING_TOOL::drawArc( DRAWSEGMENT*& aGraphic )
|
||||||
|
|
||||||
grid.SetSnap( !evt->Modifier( MD_SHIFT ) );
|
grid.SetSnap( !evt->Modifier( MD_SHIFT ) );
|
||||||
grid.SetUseGrid( !evt->Modifier( MD_ALT ) );
|
grid.SetUseGrid( !evt->Modifier( MD_ALT ) );
|
||||||
VECTOR2I cursorPos = grid.BestSnapAnchor( m_controls->GetCursorPosition(), aGraphic );
|
m_controls->SetSnapping( !evt->Modifier( MD_ALT ) );
|
||||||
|
VECTOR2I cursorPos = grid.BestSnapAnchor( m_controls->GetMousePosition(), aGraphic );
|
||||||
|
|
||||||
if( evt->IsClick( BUT_LEFT ) )
|
if( evt->IsClick( BUT_LEFT ) )
|
||||||
{
|
{
|
||||||
|
@ -1359,14 +1361,15 @@ void DRAWING_TOOL::runPolygonEventLoop( POLYGON_GEOM_MANAGER& polyGeomMgr )
|
||||||
STATUS_TEXT_POPUP status( m_frame );
|
STATUS_TEXT_POPUP status( m_frame );
|
||||||
status.SetTextColor( wxColour( 255, 0, 0 ) );
|
status.SetTextColor( wxColour( 255, 0, 0 ) );
|
||||||
status.SetText( _( "Self-intersecting polygons are not allowed" ) );
|
status.SetText( _( "Self-intersecting polygons are not allowed" ) );
|
||||||
m_controls->SetSnapping( false );
|
m_controls->SetSnapping( true );
|
||||||
|
|
||||||
while( OPT_TOOL_EVENT evt = Wait() )
|
while( OPT_TOOL_EVENT evt = Wait() )
|
||||||
{
|
{
|
||||||
LSET layers( m_frame->GetActiveLayer() );
|
LSET layers( m_frame->GetActiveLayer() );
|
||||||
grid.SetSnap( !evt->Modifier( MD_SHIFT ) );
|
grid.SetSnap( !evt->Modifier( MD_SHIFT ) );
|
||||||
grid.SetUseGrid( !evt->Modifier( MD_ALT ) );
|
grid.SetUseGrid( !evt->Modifier( MD_ALT ) );
|
||||||
VECTOR2I cursorPos = grid.BestSnapAnchor( m_controls->GetCursorPosition(), layers );
|
m_controls->SetSnapping( !evt->Modifier( MD_ALT ) );
|
||||||
|
VECTOR2I cursorPos = grid.BestSnapAnchor( m_controls->GetMousePosition(), layers );
|
||||||
|
|
||||||
if( TOOL_EVT_UTILS::IsCancelInteractive( *evt ) )
|
if( TOOL_EVT_UTILS::IsCancelInteractive( *evt ) )
|
||||||
{
|
{
|
||||||
|
|
|
@ -359,7 +359,6 @@ int EDIT_TOOL::Main( const TOOL_EVENT& aEvent )
|
||||||
|
|
||||||
Activate();
|
Activate();
|
||||||
controls->ShowCursor( true );
|
controls->ShowCursor( true );
|
||||||
controls->SetSnapping( false );
|
|
||||||
controls->SetAutoPan( true );
|
controls->SetAutoPan( true );
|
||||||
|
|
||||||
auto curr_item = static_cast<BOARD_ITEM*>( selection.Front() );
|
auto curr_item = static_cast<BOARD_ITEM*>( selection.Front() );
|
||||||
|
@ -374,6 +373,7 @@ int EDIT_TOOL::Main( const TOOL_EVENT& aEvent )
|
||||||
{
|
{
|
||||||
grid.SetSnap( !evt->Modifier( MD_SHIFT ) );
|
grid.SetSnap( !evt->Modifier( MD_SHIFT ) );
|
||||||
grid.SetUseGrid( !evt->Modifier( MD_ALT ) );
|
grid.SetUseGrid( !evt->Modifier( MD_ALT ) );
|
||||||
|
controls->SetSnapping( !evt->Modifier( MD_ALT ) );
|
||||||
|
|
||||||
if( evt->IsAction( &PCB_ACTIONS::editActivate ) ||
|
if( evt->IsAction( &PCB_ACTIONS::editActivate ) ||
|
||||||
evt->IsAction( &PCB_ACTIONS::move ) ||
|
evt->IsAction( &PCB_ACTIONS::move ) ||
|
||||||
|
@ -381,7 +381,7 @@ int EDIT_TOOL::Main( const TOOL_EVENT& aEvent )
|
||||||
{
|
{
|
||||||
if( m_dragging && evt->Category() == TC_MOUSE )
|
if( m_dragging && evt->Category() == TC_MOUSE )
|
||||||
{
|
{
|
||||||
m_cursor = grid.BestSnapAnchor( controls->GetCursorPosition(), item_layers );
|
m_cursor = grid.BestSnapAnchor( controls->GetMousePosition(), item_layers );
|
||||||
VECTOR2I movement( m_cursor - prevPos );
|
VECTOR2I movement( m_cursor - prevPos );
|
||||||
selection.SetReferencePoint( m_cursor );
|
selection.SetReferencePoint( m_cursor );
|
||||||
|
|
||||||
|
@ -1207,14 +1207,14 @@ int EDIT_TOOL::MeasureTool( const TOOL_EVENT& aEvent )
|
||||||
bool originSet = false;
|
bool originSet = false;
|
||||||
|
|
||||||
controls.ShowCursor( true );
|
controls.ShowCursor( true );
|
||||||
controls.SetSnapping( false );
|
|
||||||
controls.SetAutoPan( false );
|
controls.SetAutoPan( false );
|
||||||
|
|
||||||
while( auto evt = Wait() )
|
while( auto evt = Wait() )
|
||||||
{
|
{
|
||||||
grid.SetSnap( !evt->Modifier( MD_SHIFT ) );
|
grid.SetSnap( !evt->Modifier( MD_SHIFT ) );
|
||||||
grid.SetUseGrid( !evt->Modifier( MD_ALT ) );
|
grid.SetUseGrid( !evt->Modifier( MD_ALT ) );
|
||||||
const VECTOR2I cursorPos = grid.BestSnapAnchor( controls.GetCursorPosition(), nullptr );
|
controls.SetSnapping( !evt->Modifier( MD_ALT ) );
|
||||||
|
const VECTOR2I cursorPos = grid.BestSnapAnchor( controls.GetMousePosition(), nullptr );
|
||||||
|
|
||||||
if( evt->IsCancel() || TOOL_EVT_UTILS::IsCancelInteractive( *evt ) || evt->IsActivate() )
|
if( evt->IsCancel() || TOOL_EVT_UTILS::IsCancelInteractive( *evt ) || evt->IsActivate() )
|
||||||
{
|
{
|
||||||
|
|
|
@ -50,7 +50,7 @@ int PICKER_TOOL::Main( const TOOL_EVENT& aEvent )
|
||||||
{
|
{
|
||||||
grid.SetSnap( !evt->Modifier( MD_SHIFT ) );
|
grid.SetSnap( !evt->Modifier( MD_SHIFT ) );
|
||||||
grid.SetUseGrid( m_cursorSnapping );
|
grid.SetUseGrid( m_cursorSnapping );
|
||||||
VECTOR2I cursorPos = grid.BestSnapAnchor( controls->GetCursorPosition(), m_layerMask );
|
VECTOR2I cursorPos = grid.BestSnapAnchor( controls->GetMousePosition(), m_layerMask );
|
||||||
|
|
||||||
if( evt->IsClick( BUT_LEFT ) )
|
if( evt->IsClick( BUT_LEFT ) )
|
||||||
{
|
{
|
||||||
|
|
|
@ -308,7 +308,6 @@ int POINT_EDITOR::OnSelectionChange( const TOOL_EVENT& aEvent )
|
||||||
PCB_BASE_EDIT_FRAME* editFrame = getEditFrame<PCB_BASE_EDIT_FRAME>();
|
PCB_BASE_EDIT_FRAME* editFrame = getEditFrame<PCB_BASE_EDIT_FRAME>();
|
||||||
|
|
||||||
controls->ShowCursor( true );
|
controls->ShowCursor( true );
|
||||||
controls->SetSnapping( false );
|
|
||||||
|
|
||||||
GRID_HELPER grid( editFrame );
|
GRID_HELPER grid( editFrame );
|
||||||
BOARD_ITEM* item = static_cast<BOARD_ITEM*>( selection.Front() );
|
BOARD_ITEM* item = static_cast<BOARD_ITEM*>( selection.Front() );
|
||||||
|
@ -338,6 +337,7 @@ int POINT_EDITOR::OnSelectionChange( const TOOL_EVENT& aEvent )
|
||||||
|
|
||||||
grid.SetSnap( !evt->Modifier( MD_SHIFT ) );
|
grid.SetSnap( !evt->Modifier( MD_SHIFT ) );
|
||||||
grid.SetUseGrid( !evt->Modifier( MD_ALT ) );
|
grid.SetUseGrid( !evt->Modifier( MD_ALT ) );
|
||||||
|
controls->SetSnapping( !evt->Modifier( MD_ALT ) );
|
||||||
|
|
||||||
if( !m_editPoints ||
|
if( !m_editPoints ||
|
||||||
evt->Matches( m_selectionTool->ClearedEvent ) ||
|
evt->Matches( m_selectionTool->ClearedEvent ) ||
|
||||||
|
|
Loading…
Reference in New Issue