New SELECTION_CONDITION subclass (OnlyTypes).
This commit is contained in:
parent
fdf5b821f0
commit
13739217b8
|
@ -76,6 +76,12 @@ SELECTION_CONDITION SELECTION_CONDITIONS::OnlyType( KICAD_T aType )
|
|||
}
|
||||
|
||||
|
||||
SELECTION_CONDITION SELECTION_CONDITIONS::OnlyTypes( const std::vector<KICAD_T>& aTypes )
|
||||
{
|
||||
return boost::bind( &SELECTION_CONDITIONS::onlyTypesFunc, _1, aTypes );
|
||||
}
|
||||
|
||||
|
||||
SELECTION_CONDITION SELECTION_CONDITIONS::Count( int aNumber )
|
||||
{
|
||||
return boost::bind( &SELECTION_CONDITIONS::countFunc, _1, aNumber );
|
||||
|
@ -178,6 +184,32 @@ bool SELECTION_CONDITIONS::onlyTypeFunc( const SELECTION& aSelection, KICAD_T aT
|
|||
}
|
||||
|
||||
|
||||
bool SELECTION_CONDITIONS::onlyTypesFunc( const SELECTION& aSelection, const std::vector<KICAD_T>& aTypes )
|
||||
{
|
||||
if( aSelection.Empty() )
|
||||
return false;
|
||||
|
||||
for( int i = 0; i < aSelection.Size(); ++i )
|
||||
{
|
||||
bool valid = false;
|
||||
|
||||
for( std::vector<KICAD_T>::const_iterator it = aTypes.begin(); it != aTypes.end(); ++it )
|
||||
{
|
||||
if( aSelection.Item<EDA_ITEM>( i )->Type() == *it )
|
||||
{
|
||||
valid = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if( !valid )
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool SELECTION_CONDITIONS::countFunc( const SELECTION& aSelection, int aNumber )
|
||||
{
|
||||
return aSelection.Size() == aNumber;
|
||||
|
|
|
@ -27,6 +27,7 @@
|
|||
|
||||
#include <boost/function.hpp>
|
||||
#include <core/typeinfo.h>
|
||||
#include <vector>
|
||||
|
||||
struct SELECTION;
|
||||
|
||||
|
@ -105,10 +106,18 @@ public:
|
|||
* Function OnlyType
|
||||
* Creates a functor that tests if the selected items are *only* of given type.
|
||||
* @param aType is the type that is searched.
|
||||
* @return Functor testing if selected items are exclusively of one type..
|
||||
* @return Functor testing if selected items are exclusively of one type.
|
||||
*/
|
||||
static SELECTION_CONDITION OnlyType( KICAD_T aType );
|
||||
|
||||
/**
|
||||
* Function OnlyTypes
|
||||
* Creates a functor that tests if the selected items are *only* of given types.
|
||||
* @param aType is a vector containing types that are searched.
|
||||
* @return Functor testing if selected items are exclusively of the requested types.
|
||||
*/
|
||||
static SELECTION_CONDITION OnlyTypes( const std::vector<KICAD_T>& aTypes );
|
||||
|
||||
/**
|
||||
* Function Count
|
||||
* Creates a functor that tests if the number of selected items is equal to the value given as
|
||||
|
@ -146,6 +155,9 @@ private:
|
|||
///> Helper function used by OnlyType()
|
||||
static bool onlyTypeFunc( const SELECTION& aSelection, KICAD_T aType );
|
||||
|
||||
///> Helper function used by OnlyTypes()
|
||||
static bool onlyTypesFunc( const SELECTION& aSelection, const std::vector<KICAD_T>& aTypes );
|
||||
|
||||
///> Helper function used by Count()
|
||||
static bool countFunc( const SELECTION& aSelection, int aNumber );
|
||||
|
||||
|
|
Loading…
Reference in New Issue