From 0c94b3239dfec3824fd45d211a9baa4be7f48de0 Mon Sep 17 00:00:00 2001 From: Seth Hillbrand Date: Tue, 28 Aug 2018 14:49:48 -0700 Subject: [PATCH] pcbnew: keep selected zone highlighted when moding When adding a cutout to a zone, it helps to have the zone highlighted so that you can see when zone you are operating on. --- pcbnew/tools/drawing_tool.cpp | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/pcbnew/tools/drawing_tool.cpp b/pcbnew/tools/drawing_tool.cpp index e2d07699fc..2335d10d30 100644 --- a/pcbnew/tools/drawing_tool.cpp +++ b/pcbnew/tools/drawing_tool.cpp @@ -1296,6 +1296,7 @@ bool DRAWING_TOOL::drawArc( DRAWSEGMENT*& aGraphic ) bool DRAWING_TOOL::getSourceZoneForAction( ZONE_MODE aMode, ZONE_CONTAINER*& aZone ) { + bool clearSelection = false; aZone = nullptr; // not an action that needs a source zone @@ -1306,17 +1307,23 @@ bool DRAWING_TOOL::getSourceZoneForAction( ZONE_MODE aMode, ZONE_CONTAINER*& aZo const SELECTION& selection = selTool->GetSelection(); if( selection.Empty() ) + { + clearSelection = true; m_toolMgr->RunAction( PCB_ACTIONS::selectionCursor, true ); + } // we want a single zone - if( selection.Size() != 1 ) - return false; - - aZone = dyn_cast( selection[0] ); + if( selection.Size() == 1 ) + aZone = dyn_cast( selection[0] ); // expected a zone, but didn't get one if( !aZone ) + { + if( clearSelection ) + m_toolMgr->RunAction( PCB_ACTIONS::selectionClear, true ); + return false; + } return true; } @@ -1434,7 +1441,10 @@ int DRAWING_TOOL::drawZone( bool aKeepout, ZONE_MODE aMode ) ZONE_CONTAINER* sourceZone = nullptr; if( !getSourceZoneForAction( aMode, sourceZone ) ) + { + m_frame->SetNoToolSelected(); return 0; + } ZONE_CREATE_HELPER::PARAMS params; @@ -1452,13 +1462,12 @@ int DRAWING_TOOL::drawZone( bool aKeepout, ZONE_MODE aMode ) auto& controls = *getViewControls(); - m_toolMgr->RunAction( PCB_ACTIONS::selectionClear, true ); - controls.ShowCursor( true ); controls.SetSnapping( true ); runPolygonEventLoop( polyGeomMgr ); + m_toolMgr->RunAction( PCB_ACTIONS::selectionClear, true ); m_frame->SetNoToolSelected(); return 0;