From 1d2fd6d271c2b2f04a5e2f8bf8d65f99dcf7b2ba Mon Sep 17 00:00:00 2001 From: Seth Hillbrand Date: Wed, 17 Nov 2021 15:36:39 -0800 Subject: [PATCH] =?UTF-8?q?Change=20persistent=2045=C2=B0=20state=20to=20o?= =?UTF-8?q?nly=20drawing?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Move/edit points have a lossy state that holds only for the time in which the tool is active. It reverts back to non-constrained after completion of the move/point edit Fixes https://gitlab.com/kicad/code/kicad/issues/9574 --- pcbnew/tools/edit_tool.cpp | 10 ++++++++-- pcbnew/tools/pcb_point_editor.cpp | 8 +++++++- pcbnew/tools/pcb_tool_base.h | 2 +- 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/pcbnew/tools/edit_tool.cpp b/pcbnew/tools/edit_tool.cpp index 89ca82e0ee..71b77b2a9d 100644 --- a/pcbnew/tools/edit_tool.cpp +++ b/pcbnew/tools/edit_tool.cpp @@ -845,6 +845,7 @@ int EDIT_TOOL::doMoveSelection( TOOL_EVENT aEvent, bool aPickReference ) TOOL_EVENT* evt = &aEvent; VECTOR2I prevPos; + bool lock45 = false; bool eatFirstMouseUp = true; bool hasRedrawn3D = false; bool allowRedraw3D = editFrame->GetDisplayOptions().m_Live3DRefresh; @@ -890,7 +891,7 @@ int EDIT_TOOL::doMoveSelection( TOOL_EVENT aEvent, bool aPickReference ) if( !selection.HasReferencePoint() ) originalPos = m_cursor; - if( Is45Limited() ) + if( lock45 ) { VECTOR2I moveVector = m_cursor - originalPos; m_cursor = originalPos + GetVectorSnapped45( moveVector ); @@ -976,7 +977,7 @@ int EDIT_TOOL::doMoveSelection( TOOL_EVENT aEvent, bool aPickReference ) // start moving with the reference point attached to the cursor grid.SetAuxAxes( false ); - if( Is45Limited() ) + if( lock45 ) { VECTOR2I moveVector = m_cursor - originalPos; m_cursor = originalPos + GetVectorSnapped45( moveVector ); @@ -1091,6 +1092,11 @@ int EDIT_TOOL::doMoveSelection( TOOL_EVENT aEvent, bool aPickReference ) break; // finish } + else if( evt->IsAction( &PCB_ACTIONS::toggle45 ) ) + { + lock45 = !lock45; + evt->SetPassEvent( false ); + } else { evt->SetPassEvent(); diff --git a/pcbnew/tools/pcb_point_editor.cpp b/pcbnew/tools/pcb_point_editor.cpp index 6c4ee822be..6907e91c35 100644 --- a/pcbnew/tools/pcb_point_editor.cpp +++ b/pcbnew/tools/pcb_point_editor.cpp @@ -429,6 +429,7 @@ int PCB_POINT_EDITOR::OnSelectionChange( const TOOL_EVENT& aEvent ) updateEditedPoint( aEvent ); m_refill = false; bool inDrag = false; + bool lock45 = false; BOARD_COMMIT commit( editFrame ); LSET snapLayers = item->GetLayerSet(); @@ -524,7 +525,7 @@ int PCB_POINT_EDITOR::OnSelectionChange( const TOOL_EVENT& aEvent ) } // The alternative constraint limits to 45 degrees - if( Is45Limited() ) + if( lock45 ) m_altConstraint->Apply(); else m_editedPoint->ApplyConstraint(); @@ -570,6 +571,11 @@ int PCB_POINT_EDITOR::OnSelectionChange( const TOOL_EVENT& aEvent ) m_refill = true; } + else if( evt->IsAction( &PCB_ACTIONS::toggle45 ) ) + { + lock45 = !lock45; + evt->SetPassEvent( false ); + } else if( evt->IsCancelInteractive() || evt->IsActivate() ) { if( inDrag ) // Restore the last change diff --git a/pcbnew/tools/pcb_tool_base.h b/pcbnew/tools/pcb_tool_base.h index 2d3fb064a2..a7048581bb 100644 --- a/pcbnew/tools/pcb_tool_base.h +++ b/pcbnew/tools/pcb_tool_base.h @@ -107,7 +107,7 @@ public: * Should the tool use its 45° mode option? * @return True if set to use 45° */ - bool Is45Limited() const; + virtual bool Is45Limited() const; protected: /**