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: /**