Browse Source

Add filtering to RequestSelection().

pull/15/head
Jeff Young 7 years ago
parent
commit
8049c07a34
  1. 27
      eeschema/tools/sch_selection_tool.cpp
  2. 5
      eeschema/tools/sch_selection_tool.h

27
eeschema/tools/sch_selection_tool.cpp

@ -24,6 +24,7 @@
#include <sch_actions.h> #include <sch_actions.h>
#include <core/typeinfo.h> #include <core/typeinfo.h>
#include <sch_item_struct.h>
#include <sch_selection_tool.h> #include <sch_selection_tool.h>
#include <sch_base_frame.h> #include <sch_base_frame.h>
#include <sch_edit_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() ) if( m_selection.Empty() )
{ {
VECTOR2D cursorPos = getViewControls()->GetCursorPosition( false ); VECTOR2D cursorPos = getViewControls()->GetCursorPosition( false );
clearSelection(); clearSelection();
SelectPoint( cursorPos );
SelectPoint( cursorPos, aFilterList );
return m_selection;
} }
else
{
// Trim an existing selection by aFilterList
return m_selection;
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;
}
} }

5
eeschema/tools/sch_selection_tool.h

@ -69,9 +69,10 @@ public:
/** /**
* Function RequestSelection() * 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() * Function selectPoint()

Loading…
Cancel
Save