From 1fb75328593926ab0ca79c37e96bdd60cf67c53b Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Sun, 29 May 2022 14:16:13 +0100 Subject: [PATCH] Prepare for a more uniform implementation of H/V/45 mode. --- pcbnew/pcb_edit_frame.cpp | 12 ++++++------ pcbnew/tools/drawing_tool.cpp | 6 +++--- pcbnew/tools/drawing_tool.h | 4 ++-- pcbnew/tools/edit_tool_move_fct.cpp | 14 +++++++------- pcbnew/tools/pcb_actions.cpp | 2 +- pcbnew/tools/pcb_actions.h | 8 ++------ pcbnew/tools/pcb_point_editor.cpp | 2 +- 7 files changed, 22 insertions(+), 26 deletions(-) diff --git a/pcbnew/pcb_edit_frame.cpp b/pcbnew/pcb_edit_frame.cpp index ec798131d0..d27c5f268b 100644 --- a/pcbnew/pcb_edit_frame.cpp +++ b/pcbnew/pcb_edit_frame.cpp @@ -778,14 +778,14 @@ void PCB_EDIT_FRAME::setupUIConditions() SELECTION_CONDITION zoneMergeCond = SELECTION_CONDITIONS::MoreThan( 1 ) && SELECTION_CONDITIONS::OnlyTypes( GENERAL_COLLECTOR::Zones ); - mgr->SetConditions( PCB_ACTIONS::zoneDuplicate, ENABLE( singleZoneCond ) ); - mgr->SetConditions( PCB_ACTIONS::drawZoneCutout, ENABLE( singleZoneCond ) ); + mgr->SetConditions( PCB_ACTIONS::zoneDuplicate, ENABLE( singleZoneCond ) ); + mgr->SetConditions( PCB_ACTIONS::drawZoneCutout, ENABLE( singleZoneCond ) ); mgr->SetConditions( PCB_ACTIONS::drawSimilarZone, ENABLE( singleZoneCond ) ); - mgr->SetConditions( PCB_ACTIONS::zoneMerge, ENABLE( zoneMergeCond ) ); - mgr->SetConditions( PCB_ACTIONS::zoneFill, ENABLE( SELECTION_CONDITIONS::MoreThan( 0 ) ) ); - mgr->SetConditions( PCB_ACTIONS::zoneUnfill, ENABLE( SELECTION_CONDITIONS::MoreThan( 0 ) ) ); + mgr->SetConditions( PCB_ACTIONS::zoneMerge, ENABLE( zoneMergeCond ) ); + mgr->SetConditions( PCB_ACTIONS::zoneFill, ENABLE( SELECTION_CONDITIONS::MoreThan( 0 ) ) ); + mgr->SetConditions( PCB_ACTIONS::zoneUnfill, ENABLE( SELECTION_CONDITIONS::MoreThan( 0 ) ) ); - mgr->SetConditions( PCB_ACTIONS::toggle45, CHECK( cond.Get45degMode() ) ); + mgr->SetConditions( PCB_ACTIONS::toggleHV45Mode, CHECK( cond.Get45degMode() ) ); #define CURRENT_TOOL( action ) mgr->SetConditions( action, CHECK( cond.CurrentTool( action ) ) ) diff --git a/pcbnew/tools/drawing_tool.cpp b/pcbnew/tools/drawing_tool.cpp index 9fb903d469..3c504cd799 100644 --- a/pcbnew/tools/drawing_tool.cpp +++ b/pcbnew/tools/drawing_tool.cpp @@ -218,7 +218,7 @@ bool DRAWING_TOOL::Init() ctxMenu.AddItem( PCB_ACTIONS::closeOutline, canCloseOutline, 200 ); ctxMenu.AddItem( PCB_ACTIONS::deleteLastPoint, canUndoPoint, 200 ); - ctxMenu.AddCheckItem( PCB_ACTIONS::toggle45, SELECTION_CONDITIONS::ShowAlways, 250 ); + ctxMenu.AddCheckItem( PCB_ACTIONS::toggleHV45Mode, SELECTION_CONDITIONS::ShowAlways, 250 ); ctxMenu.AddSeparator( 500 ); std::shared_ptr viaSizeMenu = std::make_shared(); @@ -1478,7 +1478,7 @@ int DRAWING_TOOL::SetAnchor( const TOOL_EVENT& aEvent ) } -int DRAWING_TOOL::ToggleLine45degMode( const TOOL_EVENT& toolEvent ) +int DRAWING_TOOL::ToggleHV45Mode( const TOOL_EVENT& toolEvent ) { #define TOGGLE( a ) a = !a @@ -2969,5 +2969,5 @@ void DRAWING_TOOL::setTransitions() Go( &DRAWING_TOOL::DrawRectangle, PCB_ACTIONS::drawTextBox.MakeEvent() ); Go( &DRAWING_TOOL::PlaceImportedGraphics, PCB_ACTIONS::placeImportedGraphics.MakeEvent() ); Go( &DRAWING_TOOL::SetAnchor, PCB_ACTIONS::setAnchor.MakeEvent() ); - Go( &DRAWING_TOOL::ToggleLine45degMode, PCB_ACTIONS::toggle45.MakeEvent() ); + Go( &DRAWING_TOOL::ToggleHV45Mode, PCB_ACTIONS::toggleHV45Mode.MakeEvent() ); } diff --git a/pcbnew/tools/drawing_tool.h b/pcbnew/tools/drawing_tool.h index e24a19176c..76e9399a26 100644 --- a/pcbnew/tools/drawing_tool.h +++ b/pcbnew/tools/drawing_tool.h @@ -195,9 +195,9 @@ public: int SetAnchor( const TOOL_EVENT& aEvent ); /** - * Toggle the 45 degree angle constraint for graphic lines. + * Toggle the horizontal/veritcal/45-degree constraint for drawing tools. */ - int ToggleLine45degMode( const TOOL_EVENT& aEvent ); + int ToggleHV45Mode( const TOOL_EVENT& toolEvent ); ///< Set up handlers for various events. void setTransitions() override; diff --git a/pcbnew/tools/edit_tool_move_fct.cpp b/pcbnew/tools/edit_tool_move_fct.cpp index 895021c56c..324c34ab16 100644 --- a/pcbnew/tools/edit_tool_move_fct.cpp +++ b/pcbnew/tools/edit_tool_move_fct.cpp @@ -259,12 +259,12 @@ bool DRC_TEST_PROVIDER_COURTYARD_CLEARANCE_ON_MOVE::Run() m_largestClearance = 0; // Currently, do not use DRC engine for calculation time reasons - #if 0 +#if 0 DRC_CONSTRAINT constraint; if( m_drcEngine->QueryWorstConstraint( COURTYARD_CLEARANCE_CONSTRAINT, constraint ) ) m_largestClearance = constraint.GetValue().Min(); - #endif +#endif testCourtyardClearances(); @@ -393,7 +393,7 @@ int EDIT_TOOL::doMoveSelection( TOOL_EVENT aEvent, bool aPickReference ) TOOL_EVENT* evt = &aEvent; VECTOR2I prevPos; - bool lock45 = false; + bool hv45Mode = false; bool eatFirstMouseUp = true; bool hasRedrawn3D = false; bool allowRedraw3D = editFrame->Settings().m_Display.m_Live3DRefresh; @@ -445,7 +445,7 @@ int EDIT_TOOL::doMoveSelection( TOOL_EVENT aEvent, bool aPickReference ) if( !selection.HasReferencePoint() ) originalPos = m_cursor; - if( lock45 ) + if( hv45Mode ) { VECTOR2I moveVector = m_cursor - originalPos; m_cursor = originalPos + GetVectorSnapped45( moveVector ); @@ -566,7 +566,7 @@ int EDIT_TOOL::doMoveSelection( TOOL_EVENT aEvent, bool aPickReference ) // start moving with the reference point attached to the cursor grid.SetAuxAxes( false ); - if( lock45 ) + if( hv45Mode ) { VECTOR2I moveVector = m_cursor - originalPos; m_cursor = originalPos + GetVectorSnapped45( moveVector ); @@ -685,9 +685,9 @@ int EDIT_TOOL::doMoveSelection( TOOL_EVENT aEvent, bool aPickReference ) break; // finish } - else if( evt->IsAction( &PCB_ACTIONS::toggle45 ) ) + else if( evt->IsAction( &PCB_ACTIONS::toggleHV45Mode ) ) { - lock45 = !lock45; + hv45Mode = !hv45Mode; evt->SetPassEvent( false ); } else diff --git a/pcbnew/tools/pcb_actions.cpp b/pcbnew/tools/pcb_actions.cpp index bc8a20ef72..f019cfe4cb 100644 --- a/pcbnew/tools/pcb_actions.cpp +++ b/pcbnew/tools/pcb_actions.cpp @@ -692,7 +692,7 @@ TOOL_ACTION PCB_ACTIONS::toggleLock( "pcbnew.EditorControl.toggleLock", _( "Toggle Lock" ), _( "Lock or unlock selected items" ), BITMAPS::lock_unlock ); -TOOL_ACTION PCB_ACTIONS::toggle45( "pcbnew.EditorControl.toggle45", +TOOL_ACTION PCB_ACTIONS::toggleHV45Mode( "pcbnew.EditorControl.toggle45", AS_GLOBAL, MD_SHIFT + ' ', "", _( "Constrain to H, V, 45" ), diff --git a/pcbnew/tools/pcb_actions.h b/pcbnew/tools/pcb_actions.h index 8200c56fed..b7d3cedc4b 100644 --- a/pcbnew/tools/pcb_actions.h +++ b/pcbnew/tools/pcb_actions.h @@ -140,7 +140,6 @@ public: static TOOL_ACTION drag45Degree; static TOOL_ACTION dragFreeAngle; - // Drawing Tool Activations static TOOL_ACTION drawLine; static TOOL_ACTION drawPolygon; @@ -210,13 +209,9 @@ public: static TOOL_ACTION routerInlineDrag; // Point Editor - /// Break outline (insert additional points to an edge) static TOOL_ACTION pointEditorAddCorner; - - /// Removes a corner static TOOL_ACTION pointEditorRemoveCorner; - // Group Tool static TOOL_ACTION groupProperties; static TOOL_ACTION pickNewGroupMember; @@ -427,7 +422,8 @@ public: static TOOL_ACTION microwaveCreateLine; - static TOOL_ACTION toggle45; + // Constrained drawing + static TOOL_ACTION toggleHV45Mode; // Locking static TOOL_ACTION toggleLock; diff --git a/pcbnew/tools/pcb_point_editor.cpp b/pcbnew/tools/pcb_point_editor.cpp index 098e4048ac..1346a2879f 100644 --- a/pcbnew/tools/pcb_point_editor.cpp +++ b/pcbnew/tools/pcb_point_editor.cpp @@ -616,7 +616,7 @@ int PCB_POINT_EDITOR::OnSelectionChange( const TOOL_EVENT& aEvent ) m_refill = true; } - else if( evt->IsAction( &PCB_ACTIONS::toggle45 ) ) + else if( evt->IsAction( &PCB_ACTIONS::toggleHV45Mode ) ) { lock45 = !lock45; evt->SetPassEvent( false );