Added the additive mode for the selection area.
This commit is contained in:
parent
2cb6e59dfd
commit
6af09fedda
|
@ -67,12 +67,14 @@ int SELECTION_TOOL::Main( TOOL_EVENT& aEvent )
|
||||||
// Main loop: keep receiving events
|
// Main loop: keep receiving events
|
||||||
while( OPT_TOOL_EVENT evt = Wait() )
|
while( OPT_TOOL_EVENT evt = Wait() )
|
||||||
{
|
{
|
||||||
|
m_additive = evt->Modifier( MB_ModShift );
|
||||||
|
|
||||||
if( evt->IsCancel() )
|
if( evt->IsCancel() )
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
// single click? Select single object
|
// single click? Select single object
|
||||||
if( evt->IsClick( MB_Left ) )
|
if( evt->IsClick( MB_Left ) )
|
||||||
selectSingle( evt->Position(), evt->Modifier( MB_ModShift ) );
|
selectSingle( evt->Position() );
|
||||||
|
|
||||||
// drag with LMB? Select multiple objects (or at least draw a selection box)
|
// drag with LMB? Select multiple objects (or at least draw a selection box)
|
||||||
if( evt->IsDrag( MB_Left ) )
|
if( evt->IsDrag( MB_Left ) )
|
||||||
|
@ -83,7 +85,7 @@ int SELECTION_TOOL::Main( TOOL_EVENT& aEvent )
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void SELECTION_TOOL::toggleSelection( BOARD_ITEM* aItem, bool aAdditive )
|
void SELECTION_TOOL::toggleSelection( BOARD_ITEM* aItem )
|
||||||
{
|
{
|
||||||
if( m_selectedItems.find( aItem ) != m_selectedItems.end() )
|
if( m_selectedItems.find( aItem ) != m_selectedItems.end() )
|
||||||
{
|
{
|
||||||
|
@ -92,7 +94,7 @@ void SELECTION_TOOL::toggleSelection( BOARD_ITEM* aItem, bool aAdditive )
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if( !aAdditive )
|
if( !m_additive )
|
||||||
clearSelection();
|
clearSelection();
|
||||||
|
|
||||||
aItem->SetSelected();
|
aItem->SetSelected();
|
||||||
|
@ -112,7 +114,7 @@ void SELECTION_TOOL::clearSelection()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void SELECTION_TOOL::selectSingle( const VECTOR2I& aWhere, bool aAdditive )
|
void SELECTION_TOOL::selectSingle( const VECTOR2I& aWhere )
|
||||||
{
|
{
|
||||||
BOARD* pcb = getModel<BOARD>( PCB_T );
|
BOARD* pcb = getModel<BOARD>( PCB_T );
|
||||||
BOARD_ITEM* item;
|
BOARD_ITEM* item;
|
||||||
|
@ -125,18 +127,18 @@ void SELECTION_TOOL::selectSingle( const VECTOR2I& aWhere, bool aAdditive )
|
||||||
switch( collector.GetCount() )
|
switch( collector.GetCount() )
|
||||||
{
|
{
|
||||||
case 0:
|
case 0:
|
||||||
if( !aAdditive )
|
if( !m_additive )
|
||||||
clearSelection();
|
clearSelection();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 1:
|
case 1:
|
||||||
toggleSelection( collector[0], aAdditive );
|
toggleSelection( collector[0] );
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
item = disambiguationMenu( &collector );
|
item = disambiguationMenu( &collector );
|
||||||
if( item )
|
if( item )
|
||||||
toggleSelection( item, aAdditive );
|
toggleSelection( item );
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -197,6 +199,9 @@ void SELECTION_TOOL::selectMultiple()
|
||||||
|
|
||||||
if( evt->IsDrag( MB_Left ) )
|
if( evt->IsDrag( MB_Left ) )
|
||||||
{
|
{
|
||||||
|
if( !m_additive )
|
||||||
|
clearSelection();
|
||||||
|
|
||||||
// Start drawing a selection box
|
// Start drawing a selection box
|
||||||
m_selArea->SetOrigin( evt->DragOrigin() );
|
m_selArea->SetOrigin( evt->DragOrigin() );
|
||||||
m_selArea->SetEnd( evt->Position() );
|
m_selArea->SetEnd( evt->Position() );
|
||||||
|
|
|
@ -57,17 +57,18 @@ public:
|
||||||
int Main( TOOL_EVENT& aEvent );
|
int Main( TOOL_EVENT& aEvent );
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void selectSingle( const VECTOR2I& aWhere, bool aAdditive );
|
void selectSingle( const VECTOR2I& aWhere );
|
||||||
void selectMultiple();
|
void selectMultiple();
|
||||||
void handleHighlight( const VECTOR2D& aP );
|
void handleHighlight( const VECTOR2D& aP );
|
||||||
BOARD_ITEM* disambiguationMenu( GENERAL_COLLECTOR* aItems );
|
BOARD_ITEM* disambiguationMenu( GENERAL_COLLECTOR* aItems );
|
||||||
BOARD_ITEM* pickSmallestComponent( GENERAL_COLLECTOR* aCollector );
|
BOARD_ITEM* pickSmallestComponent( GENERAL_COLLECTOR* aCollector );
|
||||||
void toggleSelection( BOARD_ITEM* aItem, bool aAdditive );
|
void toggleSelection( BOARD_ITEM* aItem );
|
||||||
void clearSelection();
|
void clearSelection();
|
||||||
|
|
||||||
std::set<BOARD_ITEM*> m_selectedItems;
|
std::set<BOARD_ITEM*> m_selectedItems;
|
||||||
SELECTION_AREA* m_selArea;
|
SELECTION_AREA* m_selArea;
|
||||||
boost::shared_ptr<CONTEXT_MENU> m_menu;
|
boost::shared_ptr<CONTEXT_MENU> m_menu;
|
||||||
|
bool m_additive;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue