Refactored out the function that selects items based on the sheetname

This commit is contained in:
Kristoffer Ödmark 2017-03-02 22:07:45 +01:00 committed by Chris Pavlina
parent 906ee77dbf
commit 69a649c093
2 changed files with 31 additions and 22 deletions

View File

@ -770,35 +770,15 @@ int SELECTION_TOOL::selectNet( const TOOL_EVENT& aEvent )
return 0;
}
int SELECTION_TOOL::selectSameSheet( const TOOL_EVENT& aEvent )
void SELECTION_TOOL::selectAllItemsOnSheet( wxString sheet )
{
if( !selectCursor( true ) )
return 0;
// this function currently only supports modules since they are only
// on one sheet.
auto item = m_selection.Front();
if( item->Type() != PCB_MODULE_T )
return 0;
if( !item )
return 0;
auto mod = dynamic_cast<MODULE*>( item );
clearSelection();
// get the lowest subsheet name for this.
wxString sheetPath = mod->GetPath();
sheetPath = sheetPath.BeforeLast( '/' );
sheetPath = sheetPath.AfterLast( '/' );
auto modules = board()->m_Modules.GetFirst();
std::list<MODULE*> modList;
// store all modules that are on that sheet
for( MODULE* mitem = modules; mitem; mitem = mitem->Next() )
{
if ( mitem != NULL && mitem->GetPath().Contains( sheetPath ) )
if ( mitem != NULL && mitem->GetPath().Contains( sheet ) )
{
modList.push_back( mitem );
}
@ -869,6 +849,30 @@ int SELECTION_TOOL::selectSameSheet( const TOOL_EVENT& aEvent )
if( i != NULL )
select( i );
}
}
int SELECTION_TOOL::selectSameSheet( const TOOL_EVENT& aEvent )
{
if( !selectCursor( true ) )
return 0;
// this function currently only supports modules since they are only
// on one sheet.
auto item = m_selection.Front();
if( item->Type() != PCB_MODULE_T )
return 0;
if( !item )
return 0;
auto mod = dynamic_cast<MODULE*>( item );
clearSelection();
// get the lowest subsheet name for this.
wxString sheetPath = mod->GetPath();
sheetPath = sheetPath.BeforeLast( '/' );
sheetPath = sheetPath.AfterLast( '/' );
selectAllItemsOnSheet(sheetPath);
// Inform other potentially interested tools
if( m_selection.Size() > 0 )

View File

@ -177,6 +177,11 @@ private:
*/
void selectAllItemsOnNet( int aNetCode );
/**
* Selects all items with the given sheet timestamp name
*/
void selectAllItemsOnSheet( wxString sheet );
///> Selects all modules belonging to same sheet.
int selectSameSheet( const TOOL_EVENT& aEvent );