Merging for non-copper zones (GAL).

This commit is contained in:
Maciej Suminski 2015-07-15 14:08:50 +02:00
parent 694ff39f53
commit 2752953f34
3 changed files with 33 additions and 17 deletions

View File

@ -73,7 +73,7 @@ private:
// lines like this make me really think about a better name for SELECTION_CONDITIONS class
bool mergeEnabled = ( SELECTION_CONDITIONS::MoreThan( 1 ) &&
/*SELECTION_CONDITIONS::OnlyType( PCB_ZONE_AREA_T ) &&*/
SELECTION_CONDITIONS::SameNet() &&
SELECTION_CONDITIONS::SameNet( true ) &&
SELECTION_CONDITIONS::SameLayer() )( selTool->GetSelection() );
Enable( getMenuId( COMMON_ACTIONS::zoneMerge ), mergeEnabled );

View File

@ -52,9 +52,9 @@ bool SELECTION_CONDITIONS::OnlyConnectedItems( const SELECTION& aSelection )
}
SELECTION_CONDITION SELECTION_CONDITIONS::SameNet()
SELECTION_CONDITION SELECTION_CONDITIONS::SameNet( bool aAllowUnconnected )
{
return boost::bind( &SELECTION_CONDITIONS::sameNetFunc, _1 );
return boost::bind( &SELECTION_CONDITIONS::sameNetFunc, _1, aAllowUnconnected );
}
@ -100,26 +100,40 @@ SELECTION_CONDITION SELECTION_CONDITIONS::LessThan( int aNumber )
}
bool SELECTION_CONDITIONS::sameNetFunc( const SELECTION& aSelection )
bool SELECTION_CONDITIONS::sameNetFunc( const SELECTION& aSelection, bool aAllowUnconnected )
{
if( aSelection.Empty() )
return false;
int netcode = -1;
int netcode = -1; // -1 stands for 'net code is not yet determined'
for( int i = 0; i < aSelection.Size(); ++i )
{
int current_netcode = -1;
const BOARD_CONNECTED_ITEM* item =
dynamic_cast<const BOARD_CONNECTED_ITEM*>( aSelection.Item<EDA_ITEM>( i ) );
if( !item )
return false;
if( item )
{
current_netcode = item->GetNetCode();
}
else
{
if( !aAllowUnconnected )
return false;
else
// if it is not a BOARD_CONNECTED_ITEM, treat it as if there was no net assigned
current_netcode = 0;
}
assert( current_netcode >= 0 );
if( netcode < 0 )
{
netcode = item->GetNetCode();
netcode = current_netcode;
if( netcode == NETINFO_LIST::UNCONNECTED )
if( netcode == NETINFO_LIST::UNCONNECTED && !aAllowUnconnected )
return false;
}
else if( netcode != item->GetNetCode() )

View File

@ -76,14 +76,13 @@ public:
/**
* Function SameNet
* Creates a functor that tests if selection contains items belonging to the same net. If there
* are items which are not of BOARD_CONNECTED_ITEM type, the result is false. If all items do
* not have any net assigned, the result is negative (technically they have the same netcode,
* but in most cases they should not be connected together).
* @return Functor testing if selected items are exclusively connected items belonging to
* the same net (and netcode > 0).
* Creates a functor that tests if selection contains items belonging to the same net or are
* unconnected if aAllowUnconnected == true.
* @param aAllowUnconnected determines if unconnected items (with no net code assigned) should
* be treated as connected to the same net.
* @return Functor testing if selected items are belonging to the same net.
*/
static SELECTION_CONDITION SameNet();
static SELECTION_CONDITION SameNet( bool aAllowUnconnected = false );
/**
* Function SameLayer
@ -146,7 +145,10 @@ public:
static SELECTION_CONDITION LessThan( int aNumber );
private:
static bool sameNetFunc( const SELECTION& aSelection );
///> Helper function used by SameNet()
static bool sameNetFunc( const SELECTION& aSelection, bool aAllowUnconnected );
///> Helper function used by SameLayer()
static bool sameLayerFunc( const SELECTION& aSelection );
///> Helper function used by HasType()