Loading pcbnew/tools/selection_tool.cpp +37 −4 Original line number Original line Diff line number Diff line Loading @@ -50,7 +50,11 @@ using boost::optional; using boost::optional; SELECTION_TOOL::SELECTION_TOOL() : SELECTION_TOOL::SELECTION_TOOL() : TOOL_INTERACTIVE( "pcbnew.InteractiveSelection" ), m_additive( false ), m_multiple( false ) TOOL_INTERACTIVE( "pcbnew.InteractiveSelection" ), SelectedEvent( TC_MESSAGE, TA_ACTION, "pcbnew.InteractiveSelection.selected" ), DeselectedEvent( TC_MESSAGE, TA_ACTION, "pcbnew.InteractiveSelection.deselected" ), ClearedEvent( TC_MESSAGE, TA_ACTION, "pcbnew.InteractiveSelection.cleared" ), m_additive( false ), m_multiple( false ) { { m_selArea = new SELECTION_AREA; m_selArea = new SELECTION_AREA; m_selection.group = new KIGFX::VIEW_GROUP; m_selection.group = new KIGFX::VIEW_GROUP; Loading Loading @@ -94,6 +98,7 @@ int SELECTION_TOOL::Main( TOOL_EVENT& aEvent ) if( evt->IsAction( &COMMON_ACTIONS::selectionSingle ) ) if( evt->IsAction( &COMMON_ACTIONS::selectionSingle ) ) { { // GetMousePosition() is used to be independent of snapping settings selectSingle( getView()->ToWorld( getViewControls()->GetMousePosition() ) ); selectSingle( getView()->ToWorld( getViewControls()->GetMousePosition() ) ); } } Loading Loading @@ -167,6 +172,10 @@ void SELECTION_TOOL::toggleSelection( BOARD_ITEM* aItem ) if( aItem->IsSelected() ) if( aItem->IsSelected() ) { { deselect( aItem ); deselect( aItem ); // Inform other potentially interested tools TOOL_EVENT deselectEvent( DeselectedEvent ); m_toolMgr->ProcessEvent( deselectEvent ); } } else else { { Loading @@ -175,7 +184,13 @@ void SELECTION_TOOL::toggleSelection( BOARD_ITEM* aItem ) // Prevent selection of invisible or inactive items // Prevent selection of invisible or inactive items if( selectable( aItem ) ) if( selectable( aItem ) ) { select( aItem ); select( aItem ); // Inform other potentially interested tools TOOL_EVENT selectEvent( SelectedEvent ); m_toolMgr->ProcessEvent( selectEvent ); } } } } } Loading Loading @@ -273,13 +288,21 @@ bool SELECTION_TOOL::selectMultiple() BOARD_ITEM* item = static_cast<BOARD_ITEM*>( it->first ); BOARD_ITEM* item = static_cast<BOARD_ITEM*>( it->first ); // Add only those items that are visible and fully within the selection box // Add only those items that are visible and fully within the selection box if( !item->IsSelected() && selectable( item ) && selectionBox.Contains( item->ViewBBox() ) ) if( !item->IsSelected() && selectable( item ) && selectionBox.Contains( item->ViewBBox() ) ) select( item ); select( item ); } } // Do not display information about selected item,as there is more than one // Do not display information about selected item,as there is more than one getEditFrame<PCB_EDIT_FRAME>()->SetCurItem( NULL ); getEditFrame<PCB_EDIT_FRAME>()->SetCurItem( NULL ); if( !m_selection.Empty() ) { // Inform other potentially interested tools TOOL_EVENT selectEvent( SelectedEvent ); m_toolMgr->ProcessEvent( selectEvent ); } break; // Stop waiting for events break; // Stop waiting for events } } } } Loading Loading @@ -313,6 +336,10 @@ void SELECTION_TOOL::clearSelection() // Do not show the context menu when there is nothing selected // Do not show the context menu when there is nothing selected SetContextMenu( &m_menu, CMENU_OFF ); SetContextMenu( &m_menu, CMENU_OFF ); // Inform other potentially interested tools TOOL_EVENT clearEvent( ClearedEvent ); m_toolMgr->ProcessEvent( clearEvent ); } } Loading Loading @@ -351,8 +378,10 @@ BOARD_ITEM* SELECTION_TOOL::disambiguationMenu( GENERAL_COLLECTOR* aCollector ) current->SetBrightened(); current->SetBrightened(); } } else else { current = NULL; current = NULL; } } } else if( evt->Action() == TA_CONTEXT_MENU_CHOICE ) else if( evt->Action() == TA_CONTEXT_MENU_CHOICE ) { { optional<int> id = evt->GetCommandId(); optional<int> id = evt->GetCommandId(); Loading Loading @@ -543,6 +572,10 @@ void SELECTION_TOOL::deselect( BOARD_ITEM* aItem ) SetContextMenu( &m_menu, CMENU_OFF ); SetContextMenu( &m_menu, CMENU_OFF ); getEditFrame<PCB_EDIT_FRAME>()->SetCurItem( NULL ); getEditFrame<PCB_EDIT_FRAME>()->SetCurItem( NULL ); } } // Inform other potentially interested tools TOOL_EVENT dupa( DeselectedEvent ); m_toolMgr->ProcessEvent( dupa ); } } Loading pcbnew/tools/selection_tool.h +5 −0 Original line number Original line Diff line number Diff line Loading @@ -114,6 +114,11 @@ public: */ */ void AddMenuItem( const TOOL_ACTION& aAction ); void AddMenuItem( const TOOL_ACTION& aAction ); // TODO comments const TOOL_EVENT SelectedEvent; const TOOL_EVENT DeselectedEvent; const TOOL_EVENT ClearedEvent; private: private: /** /** * Function selectSingle() * Function selectSingle() Loading Loading
pcbnew/tools/selection_tool.cpp +37 −4 Original line number Original line Diff line number Diff line Loading @@ -50,7 +50,11 @@ using boost::optional; using boost::optional; SELECTION_TOOL::SELECTION_TOOL() : SELECTION_TOOL::SELECTION_TOOL() : TOOL_INTERACTIVE( "pcbnew.InteractiveSelection" ), m_additive( false ), m_multiple( false ) TOOL_INTERACTIVE( "pcbnew.InteractiveSelection" ), SelectedEvent( TC_MESSAGE, TA_ACTION, "pcbnew.InteractiveSelection.selected" ), DeselectedEvent( TC_MESSAGE, TA_ACTION, "pcbnew.InteractiveSelection.deselected" ), ClearedEvent( TC_MESSAGE, TA_ACTION, "pcbnew.InteractiveSelection.cleared" ), m_additive( false ), m_multiple( false ) { { m_selArea = new SELECTION_AREA; m_selArea = new SELECTION_AREA; m_selection.group = new KIGFX::VIEW_GROUP; m_selection.group = new KIGFX::VIEW_GROUP; Loading Loading @@ -94,6 +98,7 @@ int SELECTION_TOOL::Main( TOOL_EVENT& aEvent ) if( evt->IsAction( &COMMON_ACTIONS::selectionSingle ) ) if( evt->IsAction( &COMMON_ACTIONS::selectionSingle ) ) { { // GetMousePosition() is used to be independent of snapping settings selectSingle( getView()->ToWorld( getViewControls()->GetMousePosition() ) ); selectSingle( getView()->ToWorld( getViewControls()->GetMousePosition() ) ); } } Loading Loading @@ -167,6 +172,10 @@ void SELECTION_TOOL::toggleSelection( BOARD_ITEM* aItem ) if( aItem->IsSelected() ) if( aItem->IsSelected() ) { { deselect( aItem ); deselect( aItem ); // Inform other potentially interested tools TOOL_EVENT deselectEvent( DeselectedEvent ); m_toolMgr->ProcessEvent( deselectEvent ); } } else else { { Loading @@ -175,7 +184,13 @@ void SELECTION_TOOL::toggleSelection( BOARD_ITEM* aItem ) // Prevent selection of invisible or inactive items // Prevent selection of invisible or inactive items if( selectable( aItem ) ) if( selectable( aItem ) ) { select( aItem ); select( aItem ); // Inform other potentially interested tools TOOL_EVENT selectEvent( SelectedEvent ); m_toolMgr->ProcessEvent( selectEvent ); } } } } } Loading Loading @@ -273,13 +288,21 @@ bool SELECTION_TOOL::selectMultiple() BOARD_ITEM* item = static_cast<BOARD_ITEM*>( it->first ); BOARD_ITEM* item = static_cast<BOARD_ITEM*>( it->first ); // Add only those items that are visible and fully within the selection box // Add only those items that are visible and fully within the selection box if( !item->IsSelected() && selectable( item ) && selectionBox.Contains( item->ViewBBox() ) ) if( !item->IsSelected() && selectable( item ) && selectionBox.Contains( item->ViewBBox() ) ) select( item ); select( item ); } } // Do not display information about selected item,as there is more than one // Do not display information about selected item,as there is more than one getEditFrame<PCB_EDIT_FRAME>()->SetCurItem( NULL ); getEditFrame<PCB_EDIT_FRAME>()->SetCurItem( NULL ); if( !m_selection.Empty() ) { // Inform other potentially interested tools TOOL_EVENT selectEvent( SelectedEvent ); m_toolMgr->ProcessEvent( selectEvent ); } break; // Stop waiting for events break; // Stop waiting for events } } } } Loading Loading @@ -313,6 +336,10 @@ void SELECTION_TOOL::clearSelection() // Do not show the context menu when there is nothing selected // Do not show the context menu when there is nothing selected SetContextMenu( &m_menu, CMENU_OFF ); SetContextMenu( &m_menu, CMENU_OFF ); // Inform other potentially interested tools TOOL_EVENT clearEvent( ClearedEvent ); m_toolMgr->ProcessEvent( clearEvent ); } } Loading Loading @@ -351,8 +378,10 @@ BOARD_ITEM* SELECTION_TOOL::disambiguationMenu( GENERAL_COLLECTOR* aCollector ) current->SetBrightened(); current->SetBrightened(); } } else else { current = NULL; current = NULL; } } } else if( evt->Action() == TA_CONTEXT_MENU_CHOICE ) else if( evt->Action() == TA_CONTEXT_MENU_CHOICE ) { { optional<int> id = evt->GetCommandId(); optional<int> id = evt->GetCommandId(); Loading Loading @@ -543,6 +572,10 @@ void SELECTION_TOOL::deselect( BOARD_ITEM* aItem ) SetContextMenu( &m_menu, CMENU_OFF ); SetContextMenu( &m_menu, CMENU_OFF ); getEditFrame<PCB_EDIT_FRAME>()->SetCurItem( NULL ); getEditFrame<PCB_EDIT_FRAME>()->SetCurItem( NULL ); } } // Inform other potentially interested tools TOOL_EVENT dupa( DeselectedEvent ); m_toolMgr->ProcessEvent( dupa ); } } Loading
pcbnew/tools/selection_tool.h +5 −0 Original line number Original line Diff line number Diff line Loading @@ -114,6 +114,11 @@ public: */ */ void AddMenuItem( const TOOL_ACTION& aAction ); void AddMenuItem( const TOOL_ACTION& aAction ); // TODO comments const TOOL_EVENT SelectedEvent; const TOOL_EVENT DeselectedEvent; const TOOL_EVENT ClearedEvent; private: private: /** /** * Function selectSingle() * Function selectSingle() Loading