Improve hittesting for Eeschema and LibEdit delete tools.
This commit is contained in:
parent
a72b5416c3
commit
2ed3bf47bb
|
@ -40,12 +40,15 @@ int EE_PICKER_TOOL::Main( const TOOL_EVENT& aEvent )
|
||||||
KIGFX::VIEW_CONTROLS* controls = getViewControls();
|
KIGFX::VIEW_CONTROLS* controls = getViewControls();
|
||||||
int finalize_state = WAIT_CANCEL;
|
int finalize_state = WAIT_CANCEL;
|
||||||
|
|
||||||
|
// To many things are off-grid in LibEdit; turn snapping off.
|
||||||
|
bool snap = !m_isLibEdit;
|
||||||
|
|
||||||
setControls();
|
setControls();
|
||||||
|
|
||||||
while( TOOL_EVENT* evt = Wait() )
|
while( TOOL_EVENT* evt = Wait() )
|
||||||
{
|
{
|
||||||
m_frame->GetCanvas()->SetCurrentCursor( wxCURSOR_BULLSEYE );
|
m_frame->GetCanvas()->SetCurrentCursor( wxCURSOR_BULLSEYE );
|
||||||
VECTOR2D cursorPos = controls->GetCursorPosition( !evt->Modifier( MD_ALT ) );
|
VECTOR2D cursorPos = controls->GetCursorPosition( snap && !evt->Modifier( MD_ALT ) );
|
||||||
|
|
||||||
if( evt->IsClick( BUT_LEFT ) )
|
if( evt->IsClick( BUT_LEFT ) )
|
||||||
{
|
{
|
||||||
|
|
|
@ -482,7 +482,7 @@ EDA_ITEM* EE_SELECTION_TOOL::SelectPoint( const VECTOR2I& aWhere, const KICAD_T*
|
||||||
// Apply some ugly heuristics to avoid disambiguation menus whenever possible
|
// Apply some ugly heuristics to avoid disambiguation menus whenever possible
|
||||||
if( collector.GetCount() > 1 && !m_skip_heuristics )
|
if( collector.GetCount() > 1 && !m_skip_heuristics )
|
||||||
{
|
{
|
||||||
guessSelectionCandidates( collector, aWhere );
|
GuessSelectionCandidates( collector, aWhere );
|
||||||
}
|
}
|
||||||
|
|
||||||
// If still more than one item we're going to have to ask the user.
|
// If still more than one item we're going to have to ask the user.
|
||||||
|
@ -516,12 +516,12 @@ EDA_ITEM* EE_SELECTION_TOOL::SelectPoint( const VECTOR2I& aWhere, const KICAD_T*
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void EE_SELECTION_TOOL::guessSelectionCandidates( EE_COLLECTOR& collector, const VECTOR2I& aPos )
|
void EE_SELECTION_TOOL::GuessSelectionCandidates( EE_COLLECTOR& collector, const VECTOR2I& aPos )
|
||||||
{
|
{
|
||||||
// There are certain parent/child and enclosure combinations that can be handled
|
// There are certain parent/child and enclosure combinations that can be handled
|
||||||
// automatically.
|
// automatically.
|
||||||
|
|
||||||
// Prefer exact hits to a sloppy ones
|
// Prefer exact hits to sloppy ones
|
||||||
int exactHits = 0;
|
int exactHits = 0;
|
||||||
|
|
||||||
for( int i = collector.GetCount() - 1; i >= 0; --i )
|
for( int i = collector.GetCount() - 1; i >= 0; --i )
|
||||||
|
|
|
@ -130,6 +130,12 @@ public:
|
||||||
|
|
||||||
void ClearSelection();
|
void ClearSelection();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Apply heuristics to try and determine a single object when multiple are found under the
|
||||||
|
* cursor.
|
||||||
|
*/
|
||||||
|
void GuessSelectionCandidates( EE_COLLECTOR& collector, const VECTOR2I& aPos );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function SelectionMenu()
|
* Function SelectionMenu()
|
||||||
* Shows a popup menu to trim the COLLECTOR passed as aEvent's parameter down to a single
|
* Shows a popup menu to trim the COLLECTOR passed as aEvent's parameter down to a single
|
||||||
|
@ -155,12 +161,6 @@ private:
|
||||||
*/
|
*/
|
||||||
bool selectMultiple();
|
bool selectMultiple();
|
||||||
|
|
||||||
/**
|
|
||||||
* Apply heuristics to try and determine a single object when multiple are found under the
|
|
||||||
* cursor.
|
|
||||||
*/
|
|
||||||
void guessSelectionCandidates( EE_COLLECTOR& collector, const VECTOR2I& aWhere );
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Allows the selection of a single item from a list via pop-up menu. The items are
|
* Allows the selection of a single item from a list via pop-up menu. The items are
|
||||||
* highlighted on the canvas when hovered in the menu. The collector is trimmed to
|
* highlighted on the canvas when hovered in the menu. The collector is trimmed to
|
||||||
|
|
|
@ -307,12 +307,14 @@ int LIB_EDIT_TOOL::DeleteItemCursor( const TOOL_EVENT& aEvent )
|
||||||
EE_COLLECTOR collector;
|
EE_COLLECTOR collector;
|
||||||
collector.m_Threshold = KiROUND( getView()->ToWorld( HITTEST_THRESHOLD_PIXELS ) );
|
collector.m_Threshold = KiROUND( getView()->ToWorld( HITTEST_THRESHOLD_PIXELS ) );
|
||||||
collector.Collect( m_frame->GetCurPart(), nonFields, (wxPoint) aPos );
|
collector.Collect( m_frame->GetCurPart(), nonFields, (wxPoint) aPos );
|
||||||
|
|
||||||
|
EE_SELECTION_TOOL* selectionTool = m_toolMgr->GetTool<EE_SELECTION_TOOL>();
|
||||||
|
selectionTool->GuessSelectionCandidates( collector, aPos );
|
||||||
|
|
||||||
EDA_ITEM* item = collector.GetCount() == 1 ? collector[ 0 ] : nullptr;
|
EDA_ITEM* item = collector.GetCount() == 1 ? collector[ 0 ] : nullptr;
|
||||||
|
|
||||||
if( m_pickerItem != item )
|
if( m_pickerItem != item )
|
||||||
{
|
{
|
||||||
EE_SELECTION_TOOL* selectionTool = m_toolMgr->GetTool<EE_SELECTION_TOOL>();
|
|
||||||
|
|
||||||
if( m_pickerItem )
|
if( m_pickerItem )
|
||||||
selectionTool->UnbrightenItem( m_pickerItem );
|
selectionTool->UnbrightenItem( m_pickerItem );
|
||||||
|
|
||||||
|
|
|
@ -979,12 +979,14 @@ int SCH_EDIT_TOOL::DeleteItemCursor( const TOOL_EVENT& aEvent )
|
||||||
EE_COLLECTOR collector;
|
EE_COLLECTOR collector;
|
||||||
collector.m_Threshold = KiROUND( getView()->ToWorld( HITTEST_THRESHOLD_PIXELS ) );
|
collector.m_Threshold = KiROUND( getView()->ToWorld( HITTEST_THRESHOLD_PIXELS ) );
|
||||||
collector.Collect( m_frame->GetScreen()->GetDrawItems(), deletableItems, (wxPoint) aPos );
|
collector.Collect( m_frame->GetScreen()->GetDrawItems(), deletableItems, (wxPoint) aPos );
|
||||||
|
|
||||||
|
EE_SELECTION_TOOL* selectionTool = m_toolMgr->GetTool<EE_SELECTION_TOOL>();
|
||||||
|
selectionTool->GuessSelectionCandidates( collector, aPos );
|
||||||
|
|
||||||
EDA_ITEM* item = collector.GetCount() == 1 ? collector[ 0 ] : nullptr;
|
EDA_ITEM* item = collector.GetCount() == 1 ? collector[ 0 ] : nullptr;
|
||||||
|
|
||||||
if( m_pickerItem != item )
|
if( m_pickerItem != item )
|
||||||
{
|
{
|
||||||
EE_SELECTION_TOOL* selectionTool = m_toolMgr->GetTool<EE_SELECTION_TOOL>();
|
|
||||||
|
|
||||||
if( m_pickerItem )
|
if( m_pickerItem )
|
||||||
selectionTool->UnbrightenItem( m_pickerItem );
|
selectionTool->UnbrightenItem( m_pickerItem );
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue