Prepare for a more uniform implementation of H/V/45 mode.

This commit is contained in:
Jeff Young 2022-05-29 14:16:13 +01:00
parent 5c3b6980a5
commit 1fb7532859
7 changed files with 22 additions and 26 deletions

View File

@ -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 ) ) )

View File

@ -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<VIA_SIZE_MENU> viaSizeMenu = std::make_shared<VIA_SIZE_MENU>();
@ -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() );
}

View File

@ -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;

View File

@ -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

View File

@ -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" ),

View File

@ -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;

View File

@ -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 );