Add filtering to RequestSelection().
This commit is contained in:
parent
e476cfcec5
commit
8049c07a34
|
@ -24,6 +24,7 @@
|
|||
|
||||
#include <sch_actions.h>
|
||||
#include <core/typeinfo.h>
|
||||
#include <sch_item_struct.h>
|
||||
#include <sch_selection_tool.h>
|
||||
#include <sch_base_frame.h>
|
||||
#include <sch_edit_frame.h>
|
||||
|
@ -313,17 +314,37 @@ void SCH_SELECTION_TOOL::guessSelectionCandidates( SCH_COLLECTOR& collector,
|
|||
}
|
||||
|
||||
|
||||
SELECTION& SCH_SELECTION_TOOL::RequestSelection()
|
||||
SELECTION& SCH_SELECTION_TOOL::RequestSelection( const KICAD_T aFilterList[] )
|
||||
{
|
||||
if( m_selection.Empty() )
|
||||
{
|
||||
VECTOR2D cursorPos = getViewControls()->GetCursorPosition( false );
|
||||
|
||||
clearSelection();
|
||||
SelectPoint( cursorPos );
|
||||
}
|
||||
SelectPoint( cursorPos, aFilterList );
|
||||
|
||||
return m_selection;
|
||||
return m_selection;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Trim an existing selection by aFilterList
|
||||
|
||||
SELECTION originalSelection( m_selection );
|
||||
|
||||
for( EDA_ITEM* item : originalSelection )
|
||||
{
|
||||
KICAD_T matchType;
|
||||
bool match = false;
|
||||
|
||||
for( const KICAD_T* p = aFilterList; (matchType = *p) != EOT && !match; ++p )
|
||||
match = ( item->Type() == matchType );
|
||||
|
||||
if( !match )
|
||||
toggleSelection( static_cast<SCH_ITEM*>( item ) );
|
||||
}
|
||||
|
||||
return m_selection;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -69,9 +69,10 @@ public:
|
|||
/**
|
||||
* Function RequestSelection()
|
||||
*
|
||||
* Similar to GetSelection(), but will run SelectCursor() first if the selection is empty.
|
||||
* Returns either an existing selection (filtered), or the selection at the current
|
||||
* cursor if the existing selection is empty.
|
||||
*/
|
||||
SELECTION& RequestSelection();
|
||||
SELECTION& RequestSelection( const KICAD_T* aFilterList = SCH_COLLECTOR::AllItems );
|
||||
|
||||
/**
|
||||
* Function selectPoint()
|
||||
|
|
Loading…
Reference in New Issue