Hotkeys for selecting trivial or copper connection (GAL).

This commit is contained in:
Maciej Suminski 2015-07-09 17:11:34 +02:00
parent 825fe8e5de
commit f0a1f6dd78
3 changed files with 67 additions and 18 deletions

View File

@ -54,11 +54,11 @@ TOOL_ACTION COMMON_ACTIONS::selectionClear( "pcbnew.InteractiveSelection.Clear",
"", "" ); // No description, it is not supposed to be shown anywhere
TOOL_ACTION COMMON_ACTIONS::selectConnection( "pcbnew.InteractiveSelection.SelectConnection",
AS_GLOBAL, 0,
AS_GLOBAL, 'U',
_( "trivial connection" ), _( "Selects a connection between two junctions." ) );
TOOL_ACTION COMMON_ACTIONS::selectCopper( "pcbnew.InteractiveSelection.SelectCopper",
AS_GLOBAL, 0,
AS_GLOBAL, 'I',
_( "copper connection" ), _( "Selects whole copper connection." ) );
TOOL_ACTION COMMON_ACTIONS::selectNet( "pcbnew.InteractiveSelection.SelectNet",

View File

@ -153,7 +153,7 @@ int SELECTION_TOOL::Main( const TOOL_EVENT& aEvent )
if( !m_additive )
clearSelection();
selectCursor( evt->Position() );
selectPoint( evt->Position() );
}
}
@ -163,7 +163,7 @@ int SELECTION_TOOL::Main( const TOOL_EVENT& aEvent )
bool emptySelection = m_selection.Empty();
if( emptySelection )
selectCursor( evt->Position() );
selectPoint( evt->Position() );
CONTEXT_MENU& contextMenu = m_menu.Generate( m_selection );
@ -177,7 +177,7 @@ int SELECTION_TOOL::Main( const TOOL_EVENT& aEvent )
else if( evt->IsDblClick( BUT_LEFT ) )
{
if( m_selection.Empty() )
selectCursor( evt->Position() );
selectPoint( evt->Position() );
m_toolMgr->RunAction( COMMON_ACTIONS::properties );
}
@ -196,7 +196,7 @@ int SELECTION_TOOL::Main( const TOOL_EVENT& aEvent )
m_preliminary = false;
// There is nothing selected, so try to select something
if( !selectCursor( getView()->ToWorld( getViewControls()->GetMousePosition() ), false ) )
if( !selectCursor() )
{
// If nothings has been selected or user wants to select more
// draw the selection box
@ -227,7 +227,7 @@ int SELECTION_TOOL::Main( const TOOL_EVENT& aEvent )
else if( evt->IsAction( &COMMON_ACTIONS::selectionCursor ) )
{
// GetMousePosition() is used, as it is independent of snapping settings
selectCursor( getView()->ToWorld( getViewControls()->GetMousePosition() ) );
selectCursor( true );
}
else if( evt->IsAction( &COMMON_ACTIONS::find ) )
@ -311,7 +311,7 @@ void SELECTION_TOOL::toggleSelection( BOARD_ITEM* aItem )
}
bool SELECTION_TOOL::selectCursor( const VECTOR2I& aWhere, bool aOnDrag )
bool SELECTION_TOOL::selectPoint( const VECTOR2I& aWhere, bool aOnDrag )
{
BOARD_ITEM* item;
GENERAL_COLLECTORS_GUIDE guide = m_frame->GetCollectorsGuide();
@ -378,6 +378,18 @@ bool SELECTION_TOOL::selectCursor( const VECTOR2I& aWhere, bool aOnDrag )
}
bool SELECTION_TOOL::selectCursor( bool aSelectAlways )
{
if( aSelectAlways || m_selection.Empty() )
{
clearSelection();
selectPoint( getView()->ToWorld( getViewControls()->GetMousePosition() ) );
}
return !m_selection.Empty();
}
bool SELECTION_TOOL::selectMultiple()
{
bool cancelled = false; // Was the tool cancelled while it was running?
@ -521,7 +533,7 @@ SELECTION_LOCK_FLAGS SELECTION_TOOL::CheckLock()
int SELECTION_TOOL::CursorSelection( const TOOL_EVENT& aEvent )
{
selectCursor( getView()->ToWorld( getViewControls()->GetMousePosition() ) );
selectCursor( true );
return 0;
}
@ -571,15 +583,26 @@ int SELECTION_TOOL::UnselectItem( const TOOL_EVENT& aEvent )
int SELECTION_TOOL::selectConnection( const TOOL_EVENT& aEvent )
{
BOARD_CONNECTED_ITEM* item = m_selection.Item<BOARD_CONNECTED_ITEM>( 0 );
int segmentCount;
bool unselect = m_selection.Empty();
if( item->Type() != PCB_TRACE_T && item->Type() != PCB_VIA_T )
if( !selectCursor( true ) )
return 0;
BOARD_CONNECTED_ITEM* item = m_selection.Item<BOARD_CONNECTED_ITEM>( 0 );
if( item->Type() != PCB_TRACE_T && item->Type() != PCB_VIA_T )
{
if( unselect )
clearSelection();
return 0;
}
clearSelection();
int segmentCount;
TRACK* trackList = getModel<BOARD>()->MarkTrace( static_cast<TRACK*>( item ), &segmentCount,
NULL, NULL, true );
NULL, NULL, true );
if( segmentCount == 0 )
return 0;
@ -600,9 +623,23 @@ int SELECTION_TOOL::selectConnection( const TOOL_EVENT& aEvent )
int SELECTION_TOOL::selectCopper( const TOOL_EVENT& aEvent )
{
bool unselect = m_selection.Empty();
if( !selectCursor( true ) )
return 0;
BOARD_CONNECTED_ITEM* item = m_selection.Item<BOARD_CONNECTED_ITEM>( 0 );
if( item->Type() != PCB_TRACE_T && item->Type() != PCB_VIA_T )
{
if( unselect )
clearSelection();
return 0;
}
std::list<BOARD_CONNECTED_ITEM*> itemsList;
RN_DATA* ratsnest = getModel<BOARD>()->GetRatsnest();
BOARD_CONNECTED_ITEM* item = m_selection.Item<BOARD_CONNECTED_ITEM>( 0 );
clearSelection();
ratsnest->GetConnectedItems( item, itemsList, (RN_ITEM_TYPE)( RN_TRACKS | RN_VIAS ) );
@ -623,9 +660,13 @@ int SELECTION_TOOL::selectCopper( const TOOL_EVENT& aEvent )
int SELECTION_TOOL::selectNet( const TOOL_EVENT& aEvent )
{
if( !selectCursor( true ) )
return 0;
BOARD_CONNECTED_ITEM* item = m_selection.Item<BOARD_CONNECTED_ITEM>( 0 );
std::list<BOARD_CONNECTED_ITEM*> itemsList;
RN_DATA* ratsnest = getModel<BOARD>()->GetRatsnest();
BOARD_CONNECTED_ITEM* item = m_selection.Item<BOARD_CONNECTED_ITEM>( 0 );
int netCode = item->GetNetCode();
clearSelection();
@ -651,7 +692,6 @@ void SELECTION_TOOL::findCallback( BOARD_ITEM* aItem )
if( aItem )
{
clearSelection();
select( aItem );
EDA_RECT bbox = aItem->GetBoundingBox();
BOX2D viewport( VECTOR2D( bbox.GetOrigin() ), VECTOR2D( bbox.GetSize() ) );

View File

@ -189,7 +189,7 @@ public:
private:
/**
* Function selectCursor()
* Function selectPoint()
* Selects an item pointed by the parameter aWhere. If there is more than one item at that
* place, there is a menu displayed that allows to choose the item.
*
@ -198,7 +198,16 @@ private:
* a menu is shown, otherise function finishes without selecting anything.
* @return True if an item was selected, false otherwise.
*/
bool selectCursor( const VECTOR2I& aWhere, bool aOnDrag = false );
bool selectPoint( const VECTOR2I& aWhere, bool aOnDrag = false );
/**
* Function selectCursor()
* Selects an item under the cursor unless there is something already selected or aSelectAlways
* is true.
* @param aSelectAlways forces to select an item even if there is an item already selected.
* @return true if eventually there is an item selected, false otherwise.
*/
bool selectCursor( bool aSelectAlways = false );
/**
* Function selectMultiple()