Don't put up double lock confirmation dialogs.

Also removes EditToolSelectionFilter which was misused in more places
than it was used correctly.  The original point of the client filter
was to move the logic to the point of use, which the
EditToolSelectionFilter sort of obviated anyway.

Fixes https://gitlab.com/kicad/code/kicad/issues/6751
This commit is contained in:
Jeff Young 2020-12-15 22:32:02 +00:00
parent d05df4a9d4
commit 5f9ed2583c
12 changed files with 252 additions and 205 deletions

View File

@ -175,23 +175,19 @@ BITMAP_DEF SCH_MARKER::GetMenuImage() const
void SCH_MARKER::Rotate( wxPoint aPosition )
{
RotatePoint( &m_Pos, aPosition, 900 );
// Marker geometry isn't user-editable
}
void SCH_MARKER::MirrorX( int aXaxis_position )
{
m_Pos.y -= aXaxis_position;
m_Pos.y = -m_Pos.y;
m_Pos.y += aXaxis_position;
// Marker geometry isn't user-editable
}
void SCH_MARKER::MirrorY( int aYaxis_position )
{
m_Pos.x -= aYaxis_position;
m_Pos.x = -m_Pos.x;
m_Pos.x += aYaxis_position;
// Marker geometry isn't user-editable
}

View File

@ -131,6 +131,18 @@ PAD& PAD::operator=( const PAD &aOther )
}
bool PAD::IsLocked() const
{
if( GetParent() )
{
FOOTPRINT* fp = static_cast<FOOTPRINT*>( GetParent() );
return fp->IsLocked() || fp->PadsLocked();
}
return false;
};
LSET PAD::PTHMask()
{
static LSET saved = LSET::AllCuMask() | LSET( 2, F_Mask, B_Mask );

View File

@ -105,6 +105,8 @@ public:
FOOTPRINT* GetParent() const;
bool IsLocked() const override;
/**
* Imports the pad settings from aMasterPad.
* The result is "this" has the same settinds (sizes, shapes ... )

View File

@ -114,18 +114,15 @@ void PCB_MARKER::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_
}
void PCB_MARKER::Rotate( const wxPoint& aRotCentre, double aAngle)
void PCB_MARKER::Rotate( const wxPoint& aRotCentre, double aAngle )
{
RotatePoint( &m_Pos, aRotCentre, aAngle );
// Marker geometry isn't user-editable
}
void PCB_MARKER::Flip( const wxPoint& aCentre, bool aFlipLeftRight )
{
if( aFlipLeftRight )
m_Pos.x = aCentre.x - ( m_Pos.x - aCentre.x );
else
m_Pos.y = aCentre.y - ( m_Pos.y - aCentre.y );
// Marker geometry isn't user-editable
}

View File

@ -1504,17 +1504,6 @@ int ROUTER_TOOL::InlineDrag( const TOOL_EVENT& aEvent )
itemsToDrag.Add( startItem );
}
if( startItem && startItem->IsLocked() )
{
KIDIALOG dlg( frame(), _( "The selected item is locked." ), _( "Confirmation" ),
wxOK | wxCANCEL | wxICON_WARNING );
dlg.SetOKLabel( _( "Drag Anyway" ) );
dlg.DoNotShowCheckbox( __FILE__, __LINE__ );
if( dlg.ShowModal() == wxID_CANCEL )
return 0;
}
GAL* gal = m_toolMgr->GetView()->GetGAL();
VECTOR2I p0 = controls()->GetCursorPosition( false );
VECTOR2I p = p0;

View File

@ -47,7 +47,6 @@
#include <pad_naming.h>
#include <view/view_controls.h>
#include <connectivity/connectivity_algo.h>
#include <connectivity/connectivity_data.h>
#include <connectivity/connectivity_items.h>
#include <confirm.h>
#include <bitmaps.h>
@ -65,62 +64,6 @@ using namespace std::placeholders;
#include <zone_filler.h>
void EditToolSelectionFilter( GENERAL_COLLECTOR& aCollector, int aFlags,
SELECTION_TOOL* selectionTool )
{
// Iterate from the back so we don't have to worry about removals.
for( int i = aCollector.GetCount() - 1; i >= 0; --i )
{
BOARD_ITEM* item = aCollector[ i ];
if( ( aFlags & EXCLUDE_LOCKED ) && item->IsLocked() )
{
aCollector.Remove( item );
}
else if( item->Type() == PCB_FP_ZONE_T )
{
FOOTPRINT* fp = static_cast<FOOTPRINT*>( item->GetParent() );
// case 1: handle locking
if( ( aFlags & EXCLUDE_LOCKED ) && fp && fp->IsLocked() )
aCollector.Remove( item );
// case 2: selection contains both the footprint and its pads - remove the pads
if( !( aFlags & INCLUDE_PADS_AND_FOOTPRINTS ) && fp && aCollector.HasItem( fp ) )
aCollector.Remove( item );
}
else if( item->Type() == PCB_PAD_T )
{
FOOTPRINT* fp = static_cast<FOOTPRINT*>( item->GetParent() );
// case 1: handle locking
if( ( aFlags & EXCLUDE_LOCKED ) && fp && fp->IsLocked() )
{
aCollector.Remove( item );
}
else if( ( aFlags & EXCLUDE_LOCKED_PADS ) && fp && fp->PadsLocked() )
{
// Pad locking is considerably "softer" than item locking
aCollector.Remove( item );
if( !fp->IsLocked() && !aCollector.HasItem( fp ) )
aCollector.Append( fp );
}
// case 2: selection contains both the footprint and its pads - remove the pads
if( !( aFlags & INCLUDE_PADS_AND_FOOTPRINTS ) && fp && aCollector.HasItem( fp ) )
aCollector.Remove( item );
}
else if( ( aFlags & EXCLUDE_TRANSIENTS ) && item->Type() == PCB_MARKER_T )
{
aCollector.Remove( item );
}
}
selectionTool->FilterCollectorForGroups( aCollector );
}
EDIT_TOOL::EDIT_TOOL() :
PCB_TOOL_BASE( "pcbnew.InteractiveEdit" ),
m_selectionTool( NULL ),
@ -302,7 +245,22 @@ int EDIT_TOOL::Drag( const TOOL_EVENT& aEvent )
PCBNEW_SELECTION& selection = m_selectionTool->RequestSelection(
[]( const VECTOR2I& aPt, GENERAL_COLLECTOR& aCollector, SELECTION_TOOL* sTool )
{
EditToolSelectionFilter( aCollector, EXCLUDE_LOCKED_PADS, sTool );
// Iterate from the back so we don't have to worry about removals.
for( int i = aCollector.GetCount() - 1; i >= 0; --i )
{
BOARD_ITEM* item = aCollector[ i ];
// We don't operate on pads; convert them to footprint selections
if( item->Type() == PCB_PAD_T )
{
aCollector.Remove( item );
if( item->GetParent() && !aCollector.HasItem( item->GetParent() ) )
aCollector.Append( item->GetParent() );
}
}
sTool->FilterCollectorForGroups( aCollector );
},
true /* prompt user regarding locked items */ );
@ -352,22 +310,37 @@ int EDIT_TOOL::doMoveSelection( TOOL_EVENT aEvent, bool aPickReference )
PCBNEW_SELECTION& selection = m_selectionTool->RequestSelection(
[]( const VECTOR2I& aPt, GENERAL_COLLECTOR& aCollector, SELECTION_TOOL* sTool )
{
EditToolSelectionFilter( aCollector, EXCLUDE_TRANSIENTS, sTool );
// Iterate from the back so we don't have to worry about removals.
for( int i = aCollector.GetCount() - 1; i >= 0; --i )
{
BOARD_ITEM* item = aCollector[ i ];
if( item->Type() == PCB_MARKER_T )
aCollector.Remove( item );
}
} );
if( m_dragging || selection.Empty() )
return 0;
LSET item_layers = selection.GetSelectionLayers();
bool unselect = selection.IsHover(); // N.B. This must be saved before the re-selection below
bool unselect = selection.IsHover(); // N.B. This must be saved before the re-selection
// below
VECTOR2I pickedReferencePoint;
// Now filter out locked pads. We cannot do this in the first RequestSelection() as we need
// the item_layers when a pad is the selection front.
// Now filter out locked and grouped items. We cannot do this in the first RequestSelection()
// as we need the item_layers when a pad is the selection front.
selection = m_selectionTool->RequestSelection(
[]( const VECTOR2I& aPt, GENERAL_COLLECTOR& aCollector, SELECTION_TOOL* sTool )
{
EditToolSelectionFilter( aCollector, EXCLUDE_LOCKED_PADS, sTool );
// Iterate from the back so we don't have to worry about removals.
for( int i = aCollector.GetCount() - 1; i >= 0; --i )
{
BOARD_ITEM* item = aCollector[ i ];
if( item->Type() == PCB_MARKER_T )
aCollector.Remove( item );
}
},
true /* prompt user regarding locked items */ );
@ -657,7 +630,14 @@ int EDIT_TOOL::ChangeTrackWidth( const TOOL_EVENT& aEvent )
const auto& selection = m_selectionTool->RequestSelection(
[]( const VECTOR2I& aPt, GENERAL_COLLECTOR& aCollector, SELECTION_TOOL* sTool )
{
EditToolSelectionFilter( aCollector, EXCLUDE_TRANSIENTS, sTool );
// Iterate from the back so we don't have to worry about removals.
for( int i = aCollector.GetCount() - 1; i >= 0; --i )
{
BOARD_ITEM* item = aCollector[ i ];
if( !dynamic_cast<TRACK*>( item ) )
aCollector.Remove( item );
}
},
true /* prompt user regarding locked items */ );
@ -723,15 +703,20 @@ int EDIT_TOOL::FilletTracks( const TOOL_EVENT& aEvent )
auto& selection = m_selectionTool->RequestSelection(
[]( const VECTOR2I& aPt, GENERAL_COLLECTOR& aCollector, SELECTION_TOOL* sTool )
{
EditToolSelectionFilter( aCollector, EXCLUDE_LOCKED_PADS | EXCLUDE_TRANSIENTS,
sTool );
// Iterate from the back so we don't have to worry about removals.
for( int i = aCollector.GetCount() - 1; i >= 0; --i )
{
BOARD_ITEM* item = aCollector[i];
if( !dynamic_cast<TRACK*>( item ) )
aCollector.Remove( item );
}
},
!m_dragging /* prompt user regarding locked items */ );
if( selection.Size() < 2 )
{
frame()->ShowInfoBarMsg(
_( "A minimum of two straight track segments must be selected." ) );
frame()->ShowInfoBarMsg( _( "At least two straight track segments must be selected." ) );
return 0;
}
@ -804,8 +789,8 @@ int EDIT_TOOL::FilletTracks( const TOOL_EVENT& aEvent )
}
else
{
// User requested to fillet these two tracks but not possible as there are other
// elements connected at that point
// User requested to fillet these two tracks but not possible as
// there are other elements connected at that point
didOneAttemptFail = true;
}
}
@ -919,7 +904,6 @@ int EDIT_TOOL::Properties( const TOOL_EVENT& aEvent )
const PCBNEW_SELECTION& selection = m_selectionTool->RequestSelection(
[]( const VECTOR2I& aPt, GENERAL_COLLECTOR& aCollector, SELECTION_TOOL* sTool )
{
EditToolSelectionFilter( aCollector, EXCLUDE_TRANSIENTS, sTool );
} );
// Tracks & vias are treated in a special way:
@ -973,8 +957,6 @@ int EDIT_TOOL::Rotate( const TOOL_EVENT& aEvent )
auto& selection = m_selectionTool->RequestSelection(
[]( const VECTOR2I& aPt, GENERAL_COLLECTOR& aCollector, SELECTION_TOOL* sTool )
{
EditToolSelectionFilter( aCollector, EXCLUDE_LOCKED_PADS | EXCLUDE_TRANSIENTS,
sTool );
},
!m_dragging /* prompt user regarding locked items */ );
@ -989,7 +971,7 @@ int EDIT_TOOL::Rotate( const TOOL_EVENT& aEvent )
if( IsFootprintEditor() )
m_commit->Modify( selection.Front() );
for( auto item : selection )
for( EDA_ITEM* item : selection )
{
if( !item->IsNew() && !IsFootprintEditor() )
{
@ -1075,8 +1057,6 @@ int EDIT_TOOL::Mirror( const TOOL_EVENT& aEvent )
auto& selection = m_selectionTool->RequestSelection(
[]( const VECTOR2I& aPt, GENERAL_COLLECTOR& aCollector, SELECTION_TOOL* sTool )
{
EditToolSelectionFilter( aCollector, EXCLUDE_LOCKED_PADS | EXCLUDE_TRANSIENTS,
sTool );
},
!m_dragging /* prompt user regarding locked items */ );
@ -1174,8 +1154,22 @@ int EDIT_TOOL::Flip( const TOOL_EVENT& aEvent )
auto& selection = m_selectionTool->RequestSelection(
[]( const VECTOR2I& aPt, GENERAL_COLLECTOR& aCollector, SELECTION_TOOL* sTool )
{
EditToolSelectionFilter( aCollector, EXCLUDE_LOCKED_PADS | EXCLUDE_TRANSIENTS,
sTool );
// Iterate from the back so we don't have to worry about removals.
for( int i = aCollector.GetCount() - 1; i >= 0; --i )
{
BOARD_ITEM* item = aCollector[i];
// We don't operate on pads; convert them to footprint selections
if( item->Type() == PCB_PAD_T )
{
aCollector.Remove( item );
if( item->GetParent() && !aCollector.HasItem( item->GetParent() ) )
aCollector.Append( item->GetParent() );
}
}
sTool->FilterCollectorForGroups( aCollector );
},
!m_dragging /* prompt user regarding locked items */ );
@ -1262,8 +1256,6 @@ int EDIT_TOOL::Remove( const TOOL_EVENT& aEvent )
selectionCopy = m_selectionTool->RequestSelection(
[]( const VECTOR2I& aPt, GENERAL_COLLECTOR& aCollector, SELECTION_TOOL* sTool )
{
EditToolSelectionFilter( aCollector, EXCLUDE_LOCKED_PADS | EXCLUDE_TRANSIENTS,
sTool );
},
true /* prompt user regarding locked items */ );
}
@ -1446,8 +1438,14 @@ int EDIT_TOOL::MoveExact( const TOOL_EVENT& aEvent )
const auto& selection = m_selectionTool->RequestSelection(
[]( const VECTOR2I& aPt, GENERAL_COLLECTOR& aCollector, SELECTION_TOOL* sTool )
{
EditToolSelectionFilter( aCollector, EXCLUDE_LOCKED_PADS | EXCLUDE_TRANSIENTS,
sTool );
// Iterate from the back so we don't have to worry about removals.
for( int i = aCollector.GetCount() - 1; i >= 0; --i )
{
BOARD_ITEM* item = aCollector[i];
if( item->Type() == PCB_MARKER_T )
aCollector.Remove( item );
}
},
true /* prompt user regarding locked items */ );
@ -1544,12 +1542,31 @@ int EDIT_TOOL::Duplicate( const TOOL_EVENT& aEvent )
bool increment = aEvent.IsAction( &PCB_ACTIONS::duplicateIncrement );
// Be sure that there is at least one item that we can modify
const auto& selection = m_selectionTool->RequestSelection(
[]( const VECTOR2I& aPt, GENERAL_COLLECTOR& aCollector, SELECTION_TOOL* sTool )
{
EditToolSelectionFilter( aCollector, EXCLUDE_LOCKED_PADS | EXCLUDE_TRANSIENTS,
sTool );
} );
const auto& selection =
m_isFootprintEditor ? m_selectionTool->RequestSelection(
[]( const VECTOR2I&, GENERAL_COLLECTOR& aCollector, SELECTION_TOOL* sTool )
{
} )
/*is board editor*/ : m_selectionTool->RequestSelection(
[]( const VECTOR2I&, GENERAL_COLLECTOR& aCollector, SELECTION_TOOL* sTool )
{
// Iterate from the back so we don't have to worry about removals.
for( int i = aCollector.GetCount() - 1; i >= 0; i-- )
{
BOARD_ITEM* item = static_cast<BOARD_ITEM*>( aCollector[i] );
// Promote pad selections to footprint selections
if( item->Type() == PCB_PAD_T )
{
aCollector.Remove( item );
if( item->GetParent() && !aCollector.HasItem( item->GetParent() ) )
aCollector.Append( item->GetParent() );
}
}
sTool->FilterCollectorForGroups( aCollector );
} );
if( selection.Empty() )
return 0;
@ -1677,12 +1694,31 @@ int EDIT_TOOL::CreateArray( const TOOL_EVENT& aEvent )
return 0;
}
const auto& selection = m_selectionTool->RequestSelection(
[]( const VECTOR2I& aPt, GENERAL_COLLECTOR& aCollector, SELECTION_TOOL* sTool )
{
EditToolSelectionFilter( aCollector, EXCLUDE_LOCKED_PADS | EXCLUDE_TRANSIENTS,
sTool );
} );
const auto& selection =
m_isFootprintEditor ? m_selectionTool->RequestSelection(
[]( const VECTOR2I&, GENERAL_COLLECTOR& aCollector, SELECTION_TOOL* sTool )
{
} )
/*is board editor*/ : m_selectionTool->RequestSelection(
[]( const VECTOR2I&, GENERAL_COLLECTOR& aCollector, SELECTION_TOOL* sTool )
{
// Iterate from the back so we don't have to worry about removals.
for( int i = aCollector.GetCount() - 1; i >= 0; i-- )
{
BOARD_ITEM* item = static_cast<BOARD_ITEM*>( aCollector[i] );
// Promote pad selections to footprint selections
if( item->Type() == PCB_PAD_T )
{
aCollector.Remove( item );
if( item->GetParent() && !aCollector.HasItem( item->GetParent() ) )
aCollector.Append( item->GetParent() );
}
}
sTool->FilterCollectorForGroups( aCollector );
} );
if( selection.Empty() )
return 0;
@ -1834,9 +1870,8 @@ int EDIT_TOOL::copyToClipboard( const TOOL_EVENT& aEvent )
PCBNEW_SELECTION& selection = m_selectionTool->RequestSelection(
[]( const VECTOR2I& aPt, GENERAL_COLLECTOR& aCollector, SELECTION_TOOL* sTool )
{
EditToolSelectionFilter( aCollector, EXCLUDE_LOCKED_PADS | EXCLUDE_TRANSIENTS,
sTool );
} );
},
aEvent.IsAction( &ACTIONS::cut ) /* prompt user regarding locked items */ );
if( !selection.Empty() )
{

View File

@ -1,7 +1,8 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2013-2015 CERN
* Copyright (C) 2013-2020 CERN
* Copyright (C) 2013-2020 KiCad Developers, see AUTHORS.txt for contributors.
* @author Maciej Suminski <maciej.suminski@cern.ch>
* @author Tomasz Wlostowski <tomasz.wlostowski@cern.ch>
*
@ -37,26 +38,14 @@ class BOARD_ITEM;
class CONNECTIVITY_DATA;
class STATUS_TEXT_POPUP;
namespace KIGFX {
namespace PREVIEW {
namespace KIGFX
{
namespace PREVIEW
{
class RULER_ITEM;
}
}
/**
* Function EditToolSelectionFilter
*
* A CLIENT_SELECTION_FILTER which promotes pad selections to their parent footprints and
* optionally excludes locked items and/or transient items (such as markers).
*/
#define EXCLUDE_LOCKED 0x0001
#define EXCLUDE_LOCKED_PADS 0x0002
#define EXCLUDE_TRANSIENTS 0x0004
#define INCLUDE_PADS_AND_FOOTPRINTS 0x0008
void EditToolSelectionFilter( GENERAL_COLLECTOR& aCollector, int aFlags, SELECTION_TOOL* sTool );
class SPECIAL_TOOLS_CONTEXT_MENU : public CONDITIONAL_MENU
{
@ -64,11 +53,11 @@ public:
SPECIAL_TOOLS_CONTEXT_MENU( TOOL_INTERACTIVE* aTool );
};
/**
/**
* EDIT_TOOL
*
* The interactive edit tool. Allows one to move, rotate, flip and change properties of items selected
* using the pcbnew.InteractiveSelection tool.
* The interactive edit tool. Allows one to move, rotate, flip and change properties of items s
* elected using the pcbnew.InteractiveSelection tool.
*/
class EDIT_TOOL : public PCB_TOOL_BASE
@ -162,7 +151,8 @@ public:
* Function FootprintFilter()
* A selection filter which prunes the selection to contain only items of type PCB_MODULE_T
*/
static void FootprintFilter( const VECTOR2I&, GENERAL_COLLECTOR& aCollector, SELECTION_TOOL* sTool );
static void FootprintFilter( const VECTOR2I&, GENERAL_COLLECTOR& aCollector,
SELECTION_TOOL* sTool );
/**
* Function PadFilter()
@ -170,6 +160,9 @@ public:
*/
static void PadFilter( const VECTOR2I&, GENERAL_COLLECTOR& aCollector, SELECTION_TOOL* sTool );
BOARD_COMMIT* GetCurrentCommit() const { return m_commit.get(); }
private:
///> Sets up handlers for various events.
void setTransitions() override;
@ -187,9 +180,6 @@ public:
*/
int cutToClipboard( const TOOL_EVENT& aEvent );
BOARD_COMMIT* GetCurrentCommit() const { return m_commit.get(); }
private:
///> Returns the right modification point (e.g. for rotation), depending on the number of
///> selected items.
bool updateModificationPoint( PCBNEW_SELECTION& aSelection );
@ -204,15 +194,12 @@ private:
const wxString& aCanceledMessage, VECTOR2I& aReferencePoint );
private:
SELECTION_TOOL* m_selectionTool; // Selection tool used for obtaining selected items
bool m_dragging; // Indicates objects are being dragged right now
VECTOR2I m_cursor; // Last cursor position (needed for getModificationPoint()
// to avoid changes of edit reference point).
std::unique_ptr<BOARD_COMMIT> m_commit;
std::unique_ptr<STATUS_TEXT_POPUP> m_statusPopup;
SELECTION_TOOL* m_selectionTool;
std::unique_ptr<BOARD_COMMIT> m_commit;
bool m_dragging; // Indicates objects are currently being dragged
VECTOR2I m_cursor; // Last cursor position (so getModificationPoint()
// can avoid changes of edit reference point).
std::unique_ptr<STATUS_TEXT_POPUP> m_statusPopup;
};
#endif

View File

@ -202,7 +202,7 @@ int GLOBAL_EDIT_TOOL::RemoveUnusedPads( const TOOL_EVENT& aEvent )
PCBNEW_SELECTION& selection = m_selectionTool->RequestSelection(
[]( const VECTOR2I& aPt, GENERAL_COLLECTOR& aCollector, SELECTION_TOOL* sTool )
{
EditToolSelectionFilter( aCollector, EXCLUDE_TRANSIENTS, sTool );
sTool->FilterCollectorForGroups( aCollector );
} );
DIALOG_UNUSED_PAD_LAYERS dlg( editFrame, selection, *m_commit );

View File

@ -287,7 +287,6 @@ int GROUP_TOOL::PickNewMember( const TOOL_EVENT& aEvent )
const PCBNEW_SELECTION& sel = m_selectionTool->RequestSelection(
[]( const VECTOR2I& aPt, GENERAL_COLLECTOR& aCollector, SELECTION_TOOL* sTool )
{
EditToolSelectionFilter( aCollector, EXCLUDE_TRANSIENTS, sTool );
} );
if( sel.Empty() )

View File

@ -145,7 +145,14 @@ size_t ALIGN_DISTRIBUTE_TOOL::GetSelections( ALIGNMENT_RECTS& aItems, ALIGNMENT_
PCBNEW_SELECTION& selection = m_selectionTool->RequestSelection(
[]( const VECTOR2I& aPt, GENERAL_COLLECTOR& aCollector, SELECTION_TOOL* sTool )
{
EditToolSelectionFilter( aCollector, EXCLUDE_TRANSIENTS, sTool );
// Iterate from the back so we don't have to worry about removals.
for( int i = aCollector.GetCount() - 1; i >= 0; --i )
{
BOARD_ITEM* item = aCollector[i];
if( item->Type() == PCB_MARKER_T )
aCollector.Remove( item );
}
} );
std::vector<BOARD_ITEM*> lockedItems;
@ -161,7 +168,14 @@ size_t ALIGN_DISTRIBUTE_TOOL::GetSelections( ALIGNMENT_RECTS& aItems, ALIGNMENT_
selection = m_selectionTool->RequestSelection(
[]( const VECTOR2I& aPt, GENERAL_COLLECTOR& aCollector, SELECTION_TOOL* sTool )
{
EditToolSelectionFilter( aCollector, EXCLUDE_LOCKED, sTool );
// Iterate from the back so we don't have to worry about removals.
for( int i = aCollector.GetCount() - 1; i >= 0; --i )
{
BOARD_ITEM* item = aCollector[i];
if( item->Type() == PCB_MARKER_T )
aCollector.Remove( item );
}
},
true /* prompt user regarding locked items */ );
@ -455,7 +469,14 @@ int ALIGN_DISTRIBUTE_TOOL::DistributeHorizontally( const TOOL_EVENT& aEvent )
PCBNEW_SELECTION& selection = m_selectionTool->RequestSelection(
[]( const VECTOR2I& aPt, GENERAL_COLLECTOR& aCollector, SELECTION_TOOL* sTool )
{
EditToolSelectionFilter( aCollector, EXCLUDE_TRANSIENTS, sTool );
// Iterate from the back so we don't have to worry about removals.
for( int i = aCollector.GetCount() - 1; i >= 0; --i )
{
BOARD_ITEM* item = aCollector[i];
if( item->Type() == PCB_MARKER_T )
aCollector.Remove( item );
}
},
true /* prompt user regarding locked items */ );
@ -567,7 +588,14 @@ int ALIGN_DISTRIBUTE_TOOL::DistributeVertically( const TOOL_EVENT& aEvent )
PCBNEW_SELECTION& selection = m_selectionTool->RequestSelection(
[]( const VECTOR2I& aPt, GENERAL_COLLECTOR& aCollector, SELECTION_TOOL* sTool )
{
EditToolSelectionFilter( aCollector, EXCLUDE_TRANSIENTS, sTool );
// Iterate from the back so we don't have to worry about removals.
for( int i = aCollector.GetCount() - 1; i >= 0; --i )
{
BOARD_ITEM* item = aCollector[i];
if( item->Type() == PCB_MARKER_T )
aCollector.Remove( item );
}
},
true /* prompt user regarding locked items */ );

View File

@ -69,7 +69,14 @@ int POSITION_RELATIVE_TOOL::PositionRelative( const TOOL_EVENT& aEvent )
const auto& selection = m_selectionTool->RequestSelection(
[]( const VECTOR2I& aPt, GENERAL_COLLECTOR& aCollector, SELECTION_TOOL* sTool )
{
EditToolSelectionFilter( aCollector, EXCLUDE_TRANSIENTS, sTool );
// Iterate from the back so we don't have to worry about removals.
for( int i = aCollector.GetCount() - 1; i >= 0; --i )
{
BOARD_ITEM* item = aCollector[i];
if( item->Type() == PCB_MARKER_T )
aCollector.Remove( item );
}
},
true /* prompt user regarding locked items */ );
@ -145,9 +152,6 @@ int POSITION_RELATIVE_TOOL::SelectPositionRelativeItem( const TOOL_EVENT& aEvent
const PCBNEW_SELECTION& sel = m_selectionTool->RequestSelection(
[]( const VECTOR2I& aPt, GENERAL_COLLECTOR& aCollector, SELECTION_TOOL* sTool )
{
EditToolSelectionFilter( aCollector,
EXCLUDE_TRANSIENTS | INCLUDE_PADS_AND_FOOTPRINTS,
sTool );
} );
if( sel.Empty() )

View File

@ -473,43 +473,6 @@ PCBNEW_SELECTION& SELECTION_TOOL::RequestSelection( CLIENT_SELECTION_FILTER aCli
m_selection.ClearReferencePoint();
}
if( aConfirmLockedItems )
{
std::vector<BOARD_ITEM*> lockedItems;
for( EDA_ITEM* item : m_selection )
{
BOARD_ITEM* boardItem = static_cast<BOARD_ITEM*>( item );
if( boardItem->IsLocked() )
lockedItems.push_back( boardItem );
}
if( !lockedItems.empty() )
{
DIALOG_LOCKED_ITEMS_QUERY dlg( frame(), lockedItems.size() );
switch( dlg.ShowModal() )
{
case wxID_OK:
// remove locked items from selection
for( BOARD_ITEM* item : lockedItems )
unselect( item );
break;
case wxID_CANCEL:
// cancel operation
ClearSelection();
break;
case wxID_APPLY:
// continue with operation with current selection
break;
}
}
}
if( aClientFilter )
{
enum DISPOSITION { BEFORE = 1, AFTER, BOTH };
@ -567,6 +530,43 @@ PCBNEW_SELECTION& SELECTION_TOOL::RequestSelection( CLIENT_SELECTION_FILTER aCli
m_frame->GetCanvas()->ForceRefresh();
}
if( aConfirmLockedItems )
{
std::vector<BOARD_ITEM*> lockedItems;
for( EDA_ITEM* item : m_selection )
{
BOARD_ITEM* boardItem = static_cast<BOARD_ITEM*>( item );
if( boardItem->IsLocked() )
lockedItems.push_back( boardItem );
}
if( !lockedItems.empty() )
{
DIALOG_LOCKED_ITEMS_QUERY dlg( frame(), lockedItems.size() );
switch( dlg.ShowModal() )
{
case wxID_OK:
// remove locked items from selection
for( BOARD_ITEM* item : lockedItems )
unselect( item );
break;
case wxID_CANCEL:
// cancel operation
ClearSelection();
break;
case wxID_APPLY:
// continue with operation with current selection
break;
}
}
}
return m_selection;
}
@ -627,8 +627,8 @@ bool SELECTION_TOOL::selectPoint( const VECTOR2I& aWhere, bool aOnDrag,
m_selection.ClearReferencePoint();
// Allow the client to do tool- or action-specific filtering to see if we
// can get down to a single item
// Allow the client to do tool- or action-specific filtering to see if we can get down
// to a single item
if( aClientFilter )
aClientFilter( aWhere, collector, this );
@ -639,9 +639,7 @@ bool SELECTION_TOOL::selectPoint( const VECTOR2I& aWhere, bool aOnDrag,
// Apply some ugly heuristics to avoid disambiguation menus whenever possible
if( collector.GetCount() > 1 && !m_skip_heuristics )
{
GuessSelectionCandidates( collector, aWhere );
}
// If still more than one item we're going to have to ask the user.
if( collector.GetCount() > 1 )