From 7e3ad4585ad4e54b7832ccdc7b78b48f90f2ce90 Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Fri, 3 May 2019 23:46:44 +0100 Subject: [PATCH] Fix issues with dragging, moving and rotating wires. --- eeschema/sch_line.cpp | 12 ++ eeschema/sch_line.h | 2 + eeschema/tools/sch_edit_tool.cpp | 209 ++++++++++++++------------ eeschema/tools/sch_edit_tool.h | 10 +- eeschema/tools/sch_editor_control.cpp | 6 +- eeschema/tools/sch_selection_tool.cpp | 80 +++++----- eeschema/tools/sch_selection_tool.h | 18 ++- 7 files changed, 186 insertions(+), 151 deletions(-) diff --git a/eeschema/sch_line.cpp b/eeschema/sch_line.cpp index 69c5005607..34510ff0c3 100644 --- a/eeschema/sch_line.cpp +++ b/eeschema/sch_line.cpp @@ -353,6 +353,18 @@ void SCH_LINE::Rotate( wxPoint aPosition ) } +void SCH_LINE::RotateStart( wxPoint aPosition ) +{ + RotatePoint( &m_start, aPosition, 900 ); +} + + +void SCH_LINE::RotateEnd( wxPoint aPosition ) +{ + RotatePoint( &m_end, aPosition, 900 ); +} + + bool SCH_LINE::IsSameQuadrant( SCH_LINE* aLine, const wxPoint& aPosition ) { wxPoint first; diff --git a/eeschema/sch_line.h b/eeschema/sch_line.h index bffe0b6252..57877d8afa 100644 --- a/eeschema/sch_line.h +++ b/eeschema/sch_line.h @@ -137,6 +137,8 @@ public: void MirrorX( int aXaxis_position ) override; void MirrorY( int aYaxis_position ) override; void Rotate( wxPoint aPosition ) override; + void RotateStart( wxPoint aPosition ); + void RotateEnd( wxPoint aPosition ); /** * Check line against \a aLine to see if it overlaps and merge if it does. diff --git a/eeschema/tools/sch_edit_tool.cpp b/eeschema/tools/sch_edit_tool.cpp index 73ea366162..3eadcd0d71 100644 --- a/eeschema/tools/sch_edit_tool.cpp +++ b/eeschema/tools/sch_edit_tool.cpp @@ -174,6 +174,10 @@ TOOL_ACTION SCH_ACTIONS::breakBus( "eeschema.InteractiveEdit.breakBus", break_line_xpm ); +// For adding to or removing from selections +#define QUIET_MODE true + + class SYMBOL_UNIT_MENU : public CONTEXT_MENU { public: @@ -241,7 +245,7 @@ SCH_EDIT_TOOL::SCH_EDIT_TOOL() : m_frame( nullptr ), m_menu( *this ), m_moveInProgress( false ), - m_totalMovement( 0, 0 ) + m_moveOffset( 0, 0 ) { } @@ -464,7 +468,7 @@ void SCH_EDIT_TOOL::Reset( RESET_REASON aReason ) if( aReason == MODEL_RELOAD ) { m_moveInProgress = false; - m_totalMovement = { 0, 0 }; + m_moveOffset = { 0, 0 }; // Init variables used by every drawing tool m_view = static_cast( getView() ); @@ -504,7 +508,8 @@ int SCH_EDIT_TOOL::Main( const TOOL_EVENT& aEvent ) // Be sure that there is at least one item that we can move. If there's no selection try // looking for the stuff under mouse cursor (i.e. Kicad old-style hover selection). SELECTION& selection = m_selectionTool->RequestSelection( movableItems ); - bool unselect = selection.IsHover(); + EDA_ITEMS dragAdditions; + bool unselect = selection.IsHover(); if( selection.Empty() ) return 0; @@ -526,10 +531,12 @@ int SCH_EDIT_TOOL::Main( const TOOL_EVENT& aEvent ) if( m_moveInProgress ) { // User must have switched from move to drag or vice-versa. Reset the moved items - // so we can start again with the current m_isDragOperation and m_totalMovement. + // so we can start again with the current m_isDragOperation and m_moveOffset. m_frame->RollbackSchematicFromUndo(); + m_selectionTool->RemoveItemsFromSel( &dragAdditions, QUIET_MODE ); m_moveInProgress = false; - // And give it a kick so it doesn't have to wait for the first mouse movement. + // And give it a kick so it doesn't have to wait for the first mouse movement to + // refresh. m_toolMgr->RunAction( SCH_ACTIONS::refreshPreview ); return 0; } @@ -545,31 +552,37 @@ int SCH_EDIT_TOOL::Main( const TOOL_EVENT& aEvent ) { if( !m_moveInProgress ) // Prepare to start moving/dragging { + //------------------------------------------------------------------------ + // Setup a drag or a move + // + for( SCH_ITEM* it = m_frame->GetScreen()->GetDrawItems(); it; it = it->Next() ) + { + if( it->IsSelected() ) + it->SetFlags( STARTPOINT | ENDPOINT | SELECTEDNODE ); + else + it->ClearFlags( STARTPOINT | ENDPOINT | SELECTEDNODE ); + } + // Add connections to the selection for a drag. // if( m_frame->GetToolId() == ID_SCH_DRAG ) { - for( unsigned i = 0; i < selection.GetSize(); ++i ) + for( EDA_ITEM* item : selection ) { - SCH_ITEM* item = static_cast( selection.GetItem( i ) ); - - item->ClearFlags( STARTPOINT | ENDPOINT ); - } - - int originalEnd = selection.GetSize(); - for( unsigned i = 0; i < originalEnd && i < selection.GetSize(); ++i ) - { - SCH_ITEM* item = static_cast( selection.GetItem( i ) ); - - if( item->IsConnectable() ) + if( static_cast( item )->IsConnectable() ) { std::vector connections; - item->GetConnectionPoints( connections ); + static_cast( item )->GetConnectionPoints( connections ); for( wxPoint point : connections ) - selectConnectedDragItems( item, point ); + getConnectedDragItems( (SCH_ITEM*) item, point, dragAdditions ); } } + + m_selectionTool->AddItemsToSel( &dragAdditions, QUIET_MODE ); + + for( EDA_ITEM* item : dragAdditions ) + saveCopyInUndoList( (SCH_ITEM*) item, UR_CHANGED, true ); } // Mark the edges of the block with dangling flags for a move. @@ -578,40 +591,31 @@ int SCH_EDIT_TOOL::Main( const TOOL_EVENT& aEvent ) { std::vector internalPoints; - for( unsigned i = 0; i < selection.GetSize(); ++i ) - { - SCH_ITEM* item = static_cast( selection.GetItem( i ) ); - item->GetEndPoints( internalPoints ); - } + for( EDA_ITEM* item : selection ) + static_cast( item )->GetEndPoints( internalPoints ); - for( unsigned i = 0; i < selection.GetSize(); ++i ) - { - SCH_ITEM* item = static_cast( selection.GetItem( i ) ); - item->UpdateDanglingState( internalPoints ); - } + for( EDA_ITEM* item : selection ) + static_cast( item )->UpdateDanglingState( internalPoints ); } - // Save items for undo. + // Generic setup // - for( unsigned i = 0; i < selection.GetSize(); ++i ) + bool first = true; + for( EDA_ITEM* item : selection ) { - SCH_ITEM* item = static_cast( selection.GetItem( i ) ); + if( item->IsNew() || ( item->GetParent() && item->GetParent()->IsSelected() ) ) + { + // already saved to undo + } + else + { + saveCopyInUndoList( (SCH_ITEM*) item, UR_CHANGED, !first ); + first = false; + } - // No need to save children of selected items - if( item->GetParent() && item->GetParent()->IsSelected() ) - continue; - - if( !item->IsNew() ) - saveCopyInUndoList( item, UR_CHANGED, i > 0 ); - } - - // Apply any initial offset in case we're coming from a previous command. - // - for( unsigned i = 0; i < selection.GetSize(); ++i ) - { - SCH_ITEM* item = static_cast( selection.GetItem( i ) ); - - moveItem( item, m_totalMovement, m_frame->GetToolId() == ID_SCH_DRAG ); + // Apply any initial offset in case we're coming from a previous command. + // + moveItem( (SCH_ITEM*) item, m_moveOffset, m_frame->GetToolId() == ID_SCH_DRAG ); } // Set up the starting position and move/drag offset @@ -656,30 +660,31 @@ int SCH_EDIT_TOOL::Main( const TOOL_EVENT& aEvent ) m_moveInProgress = true; } + //------------------------------------------------------------------------ // Follow the mouse // m_cursor = controls->GetCursorPosition(); - VECTOR2I movement( m_cursor - prevPos ); + VECTOR2I delta( m_cursor - prevPos ); selection.SetReferencePoint( m_cursor ); - m_totalMovement += movement; + m_moveOffset += delta; prevPos = m_cursor; - for( int i = 0; i < selection.GetSize(); ++i ) + for( EDA_ITEM* item : selection ) { - SCH_ITEM* item = static_cast( selection.GetItem( i ) ); - // Don't double move pins, fields, etc. if( item->GetParent() && item->GetParent()->IsSelected() ) continue; - moveItem( item, movement, m_frame->GetToolId() == ID_SCH_DRAG ); + moveItem( (SCH_ITEM*) item, delta, m_frame->GetToolId() == ID_SCH_DRAG ); updateView( item ); } m_frame->UpdateMsgPanel(); } - + //------------------------------------------------------------------------ + // Handle cancel + // else if( TOOL_EVT_UTILS::IsCancelInteractive( evt.get() ) ) { m_toolMgr->RunAction( SCH_ACTIONS::clearSelection, true ); @@ -689,14 +694,14 @@ int SCH_EDIT_TOOL::Main( const TOOL_EVENT& aEvent ) break; } - + //------------------------------------------------------------------------ + // Handle TOOL_ACTION special cases + // else if( evt->Action() == TA_UNDO_REDO_PRE ) { unselect = true; break; } - - // Handle TOOL_ACTION special cases else if( evt->Category() == TC_COMMAND ) { if( evt->IsAction( &SCH_ACTIONS::doDelete ) ) @@ -735,12 +740,16 @@ int SCH_EDIT_TOOL::Main( const TOOL_EVENT& aEvent ) } } } - + //------------------------------------------------------------------------ + // Handle context menu + // else if( evt->IsClick( BUT_RIGHT ) ) { m_menu.ShowContextMenu( selection ); } - + //------------------------------------------------------------------------ + // Handle drop + // else if( evt->IsMouseUp( BUT_LEFT ) || evt->IsClick( BUT_LEFT ) ) { break; // Finish @@ -754,7 +763,7 @@ int SCH_EDIT_TOOL::Main( const TOOL_EVENT& aEvent ) controls->SetAutoPan( false ); if( !chain_commands ) - m_totalMovement = { 0, 0 }; + m_moveOffset = { 0, 0 }; m_moveInProgress = false; m_frame->SetNoToolSelected(); @@ -766,6 +775,8 @@ int SCH_EDIT_TOOL::Main( const TOOL_EVENT& aEvent ) if( unselect ) m_toolMgr->RunAction( SCH_ACTIONS::clearSelection, true ); + else + m_selectionTool->RemoveItemsFromSel( &dragAdditions, QUIET_MODE ); if( restore_state ) { @@ -783,40 +794,35 @@ int SCH_EDIT_TOOL::Main( const TOOL_EVENT& aEvent ) } -void SCH_EDIT_TOOL::selectConnectedDragItems( SCH_ITEM* aSourceItem, wxPoint aPoint ) +void SCH_EDIT_TOOL::getConnectedDragItems( SCH_ITEM* aItem, wxPoint aPoint, EDA_ITEMS& aList ) { - for( SCH_ITEM* item = m_frame->GetScreen()->GetDrawItems(); item; item = item->Next() ) + for( SCH_ITEM* test = m_frame->GetScreen()->GetDrawItems(); test; test = test->Next() ) { - if( item->IsSelected() || !item->IsConnectable() || !item->CanConnect( aSourceItem ) ) + if( test->IsSelected() || !test->IsConnectable() || !test->CanConnect( aItem ) ) continue; - bool doSelect = false; - - switch( item->Type() ) + switch( test->Type() ) { default: case SCH_LINE_T: { // Select wires/busses that are connected at one end and/or the other. Any // unconnected ends must be flagged (STARTPOINT or ENDPOINT). - SCH_LINE* line = (SCH_LINE*) item; - - if( !line->IsSelected() ) - line->SetFlags( STARTPOINT | ENDPOINT ); + SCH_LINE* line = (SCH_LINE*) test; if( line->GetStartPoint() == aPoint ) { - line->ClearFlags( STARTPOINT ); + if( !( line->GetFlags() & SELECTEDNODE ) ) + aList.push_back( line ); - if( !line->IsSelected() ) - doSelect = true; + line->SetFlags( STARTPOINT | SELECTEDNODE ); } else if( line->GetEndPoint() == aPoint ) { - line->ClearFlags( ENDPOINT ); + if( !( line->GetFlags() & SELECTEDNODE ) ) + aList.push_back( line ); - if( !line->IsSelected() ) - doSelect = true; + line->SetFlags( ENDPOINT | SELECTEDNODE ); } break; } @@ -830,8 +836,8 @@ void SCH_EDIT_TOOL::selectConnectedDragItems( SCH_ITEM* aSourceItem, wxPoint aPo case SCH_NO_CONNECT_T: case SCH_JUNCTION_T: // Select connected items that have no wire between them. - if( aSourceItem->Type() != SCH_LINE_T && item->IsConnected( aPoint ) ) - doSelect = true; + if( aItem->Type() != SCH_LINE_T && test->IsConnected( aPoint ) ) + aList.push_back( test ); break; @@ -841,25 +847,19 @@ void SCH_EDIT_TOOL::selectConnectedDragItems( SCH_ITEM* aSourceItem, wxPoint aPo case SCH_BUS_WIRE_ENTRY_T: case SCH_BUS_BUS_ENTRY_T: // Select labels and bus entries that are connected to a wire being moved. - if( aSourceItem->Type() == SCH_LINE_T ) + if( aItem->Type() == SCH_LINE_T ) { std::vector connections; - item->GetConnectionPoints( connections ); + test->GetConnectionPoints( connections ); for( wxPoint& point : connections ) { - if( aSourceItem->HitTest( point ) ) - doSelect = true; + if( aItem->HitTest( point ) ) + aList.push_back( test ); } } break; } - - if( doSelect ) - { - m_selectionTool->AddItemToSel( item, true /*quiet mode*/ ); - saveCopyInUndoList( item, UR_CHANGED, true ); - } } } @@ -869,17 +869,13 @@ void SCH_EDIT_TOOL::moveItem( SCH_ITEM* aItem, VECTOR2I aDelta, bool isDrag ) switch( aItem->Type() ) { case SCH_LINE_T: - { - SCH_LINE* line = (SCH_LINE*) aItem; + if( aItem->GetFlags() & STARTPOINT ) + static_cast( aItem )->MoveStart( (wxPoint) aDelta ); + + if( aItem->GetFlags() & ENDPOINT ) + static_cast( aItem )->MoveEnd( (wxPoint) aDelta ); - if( isDrag && ( line->GetFlags() & STARTPOINT ) ) - line->MoveEnd( (wxPoint)aDelta ); - else if( isDrag && ( line->GetFlags() & ENDPOINT ) ) - line->MoveStart( (wxPoint)aDelta ); - else - line->Move( (wxPoint)aDelta ); break; - } case SCH_PIN_T: case SCH_FIELD_T: @@ -887,7 +883,7 @@ void SCH_EDIT_TOOL::moveItem( SCH_ITEM* aItem, VECTOR2I aDelta, bool isDrag ) break; default: - aItem->Move( (wxPoint)aDelta ); + aItem->Move( (wxPoint) aDelta ); break; } @@ -1027,7 +1023,20 @@ int SCH_EDIT_TOOL::Rotate( const TOOL_EVENT& aEvent ) if( !moving ) saveCopyInUndoList( item, UR_CHANGED, ii > 0 ); - item->Rotate( rotPoint ); + if( item->Type() == SCH_LINE_T ) + { + SCH_LINE* line = (SCH_LINE*) item; + + if( item->GetFlags() & STARTPOINT ) + line->RotateStart( rotPoint ); + + if( item->GetFlags() & ENDPOINT ) + line->RotateEnd( rotPoint ); + } + else + { + item->Rotate( rotPoint ); + } connections |= item->IsConnectable(); m_frame->RefreshItem( item ); @@ -1217,7 +1226,7 @@ int SCH_EDIT_TOOL::Duplicate( const TOOL_EVENT& aEvent ) if( selection.Front()->IsNew() ) return 0; - std::vector newItems; + EDA_ITEMS newItems; // Keep track of existing sheet paths. Duplicating a selection can modify this list bool copiedSheets = false; diff --git a/eeschema/tools/sch_edit_tool.h b/eeschema/tools/sch_edit_tool.h index fe3f6be8ee..9c4b620093 100644 --- a/eeschema/tools/sch_edit_tool.h +++ b/eeschema/tools/sch_edit_tool.h @@ -86,10 +86,10 @@ public: private: void moveItem( SCH_ITEM* aItem, VECTOR2I aDelta, bool isDrag ); - ///> Selects additional items for a drag operation. - ///> Connected items with no wire are selected (as there is no wire to adjust for the drag). - ///> Connected wires are selected with any un-connected ends flagged (STARTPOINT or ENDPOINT). - void selectConnectedDragItems( SCH_ITEM* aSourceItem, wxPoint aPoint ); + ///> Finds additional items for a drag operation. + ///> Connected items with no wire are included (as there is no wire to adjust for the drag). + ///> Connected wires are included with any un-connected ends flagged (STARTPOINT or ENDPOINT). + void getConnectedDragItems( SCH_ITEM* aItem, wxPoint aPoint, EDA_ITEMS& aList ); ///> Returns the right modification point (e.g. for rotation), depending on the number of ///> selected items. @@ -118,7 +118,7 @@ private: bool m_moveInProgress; ///> Used for chaining commands - VECTOR2I m_totalMovement; + VECTOR2I m_moveOffset; ///> Last cursor position (needed for getModificationPoint() to avoid changes ///> of edit reference point). diff --git a/eeschema/tools/sch_editor_control.cpp b/eeschema/tools/sch_editor_control.cpp index 530f299d3a..1cdb4746ff 100644 --- a/eeschema/tools/sch_editor_control.cpp +++ b/eeschema/tools/sch_editor_control.cpp @@ -573,7 +573,7 @@ int SCH_EDITOR_CONTROL::Paste( const TOOL_EVENT& aEvent ) // SCH_LEGACY_PLUGIN added the items to the DLIST, but not to the view or anything // else. Pull them back out to start with. // - std::vector loadedItems; + EDA_ITEMS loadedItems; SCH_ITEM* next = nullptr; // We also make sure any pasted sheets will not cause recursion in the destination. @@ -646,7 +646,7 @@ int SCH_EDITOR_CONTROL::Paste( const TOOL_EVENT& aEvent ) for( int i = 0; i < loadedItems.size(); ++i ) { - SCH_ITEM* item = loadedItems[i]; + EDA_ITEM* item = loadedItems[i]; if( item->Type() == SCH_COMPONENT_T ) { @@ -660,7 +660,7 @@ int SCH_EDITOR_CONTROL::Paste( const TOOL_EVENT& aEvent ) } item->SetFlags( IS_NEW | IS_MOVED ); - m_frame->AddItemToScreenAndUndoList( item, i > 0 ); + m_frame->AddItemToScreenAndUndoList( (SCH_ITEM*) item, i > 0 ); } if( sheetsPasted ) diff --git a/eeschema/tools/sch_selection_tool.cpp b/eeschema/tools/sch_selection_tool.cpp index 78baf6f08d..78f469e05d 100644 --- a/eeschema/tools/sch_selection_tool.cpp +++ b/eeschema/tools/sch_selection_tool.cpp @@ -659,22 +659,6 @@ int SCH_SELECTION_TOOL::SelectConnection( const TOOL_EVENT& aEvent ) } -int SCH_SELECTION_TOOL::AddItemsToSel( const TOOL_EVENT& aEvent ) -{ - std::vector* items = aEvent.Parameter*>(); - - if( items ) - { - for( SCH_ITEM* item : *items ) - select( item ); - - m_toolMgr->ProcessEvent( EVENTS::SelectedEvent ); - } - - return 0; -} - - int SCH_SELECTION_TOOL::AddItemToSel( const TOOL_EVENT& aEvent ) { AddItemToSel( aEvent.Parameter() ); @@ -682,7 +666,7 @@ int SCH_SELECTION_TOOL::AddItemToSel( const TOOL_EVENT& aEvent ) } -void SCH_SELECTION_TOOL::AddItemToSel( SCH_ITEM* aItem, bool aQuietMode ) +void SCH_SELECTION_TOOL::AddItemToSel( EDA_ITEM* aItem, bool aQuietMode ) { if( aItem ) { @@ -695,22 +679,27 @@ void SCH_SELECTION_TOOL::AddItemToSel( SCH_ITEM* aItem, bool aQuietMode ) } -int SCH_SELECTION_TOOL::RemoveItemsFromSel( const TOOL_EVENT& aEvent ) +int SCH_SELECTION_TOOL::AddItemsToSel( const TOOL_EVENT& aEvent ) { - std::vector* items = aEvent.Parameter*>(); - - if( items ) - { - for( SCH_ITEM* item : *items ) - unselect( item ); - - m_toolMgr->ProcessEvent( EVENTS::UnselectedEvent ); - } - + AddItemsToSel( aEvent.Parameter(), false ); return 0; } +void SCH_SELECTION_TOOL::AddItemsToSel( EDA_ITEMS* aList, bool aQuietMode ) +{ + if( aList ) + { + for( EDA_ITEM* item : *aList ) + select( item ); + + // Inform other potentially interested tools + if( !aQuietMode ) + m_toolMgr->ProcessEvent( EVENTS::SelectedEvent ); + } +} + + int SCH_SELECTION_TOOL::RemoveItemFromSel( const TOOL_EVENT& aEvent ) { RemoveItemFromSel( aEvent.Parameter() ); @@ -718,7 +707,7 @@ int SCH_SELECTION_TOOL::RemoveItemFromSel( const TOOL_EVENT& aEvent ) } -void SCH_SELECTION_TOOL::RemoveItemFromSel( SCH_ITEM* aItem, bool aQuietMode ) +void SCH_SELECTION_TOOL::RemoveItemFromSel( EDA_ITEM* aItem, bool aQuietMode ) { if( aItem ) { @@ -731,6 +720,27 @@ void SCH_SELECTION_TOOL::RemoveItemFromSel( SCH_ITEM* aItem, bool aQuietMode ) } +int SCH_SELECTION_TOOL::RemoveItemsFromSel( const TOOL_EVENT& aEvent ) +{ + RemoveItemsFromSel( aEvent.Parameter(), false ); + return 0; +} + + +void SCH_SELECTION_TOOL::RemoveItemsFromSel( EDA_ITEMS* aList, bool aQuietMode ) +{ + if( aList ) + { + for( EDA_ITEM* item : *aList ) + unselect( item ); + + // Inform other potentially interested tools + if( !aQuietMode ) + m_toolMgr->ProcessEvent( EVENTS::UnselectedEvent ); + } +} + + int SCH_SELECTION_TOOL::ClearSelection( const TOOL_EVENT& aEvent ) { clearSelection(); @@ -830,7 +840,7 @@ bool SCH_SELECTION_TOOL::doSelectionMenu( SCH_COLLECTOR* aCollector ) } -bool SCH_SELECTION_TOOL::selectable( const SCH_ITEM* aItem, bool checkVisibilityOnly ) const +bool SCH_SELECTION_TOOL::selectable( const EDA_ITEM* aItem, bool checkVisibilityOnly ) const { // NOTE: in the future this is where eeschema layer/itemtype visibility will be handled @@ -873,7 +883,7 @@ void SCH_SELECTION_TOOL::clearSelection() } -void SCH_SELECTION_TOOL::toggleSelection( SCH_ITEM* aItem, bool aForce ) +void SCH_SELECTION_TOOL::toggleSelection( EDA_ITEM* aItem, bool aForce ) { if( aItem->IsSelected() ) { @@ -902,19 +912,19 @@ void SCH_SELECTION_TOOL::toggleSelection( SCH_ITEM* aItem, bool aForce ) } -void SCH_SELECTION_TOOL::select( SCH_ITEM* aItem ) +void SCH_SELECTION_TOOL::select( EDA_ITEM* aItem ) { highlight( aItem, SELECTED, &m_selection ); } -void SCH_SELECTION_TOOL::unselect( SCH_ITEM* aItem ) +void SCH_SELECTION_TOOL::unselect( EDA_ITEM* aItem ) { unhighlight( aItem, SELECTED, &m_selection ); } -void SCH_SELECTION_TOOL::highlight( SCH_ITEM* aItem, int aMode, SELECTION* aGroup ) +void SCH_SELECTION_TOOL::highlight( EDA_ITEM* aItem, int aMode, SELECTION* aGroup ) { if( aMode == SELECTED ) aItem->SetSelected(); @@ -969,7 +979,7 @@ void SCH_SELECTION_TOOL::highlight( SCH_ITEM* aItem, int aMode, SELECTION* aGrou } -void SCH_SELECTION_TOOL::unhighlight( SCH_ITEM* aItem, int aMode, SELECTION* aGroup ) +void SCH_SELECTION_TOOL::unhighlight( EDA_ITEM* aItem, int aMode, SELECTION* aGroup ) { if( aMode == SELECTED ) aItem->ClearSelected(); diff --git a/eeschema/tools/sch_selection_tool.h b/eeschema/tools/sch_selection_tool.h index b9788a12e1..f1527764bd 100644 --- a/eeschema/tools/sch_selection_tool.h +++ b/eeschema/tools/sch_selection_tool.h @@ -105,12 +105,14 @@ public: bool* aSelectionCancelledFlag = NULL, bool aCheckLocked = false ); int AddItemToSel( const TOOL_EVENT& aEvent ); - void AddItemToSel( SCH_ITEM* aItem, bool aQuietMode = false ); + void AddItemToSel( EDA_ITEM* aItem, bool aQuietMode = false ); int AddItemsToSel( const TOOL_EVENT& aEvent ); + void AddItemsToSel( EDA_ITEMS* aList, bool aQuietMode = false ); int RemoveItemFromSel( const TOOL_EVENT& aEvent ); - void RemoveItemFromSel( SCH_ITEM* aItem, bool aQuietMode = false ); + void RemoveItemFromSel( EDA_ITEM* aItem, bool aQuietMode = false ); int RemoveItemsFromSel( const TOOL_EVENT& aEvent ); + void RemoveItemsFromSel( EDA_ITEMS* aList, bool aQuietMode = false ); ///> Find (but don't select) node under cursor SCH_ITEM* GetNode( VECTOR2I aPosition ); @@ -170,7 +172,7 @@ private: * @param aItem is the item to have selection status changed. * @param aForce causes the toggle to happen without checking selectability */ - void toggleSelection( SCH_ITEM* aItem, bool aForce = false ); + void toggleSelection( EDA_ITEM* aItem, bool aForce = false ); /** * Function selectable() @@ -178,7 +180,7 @@ private: * * @return True if the item fulfills conditions to be selected. */ - bool selectable( const SCH_ITEM* aItem, bool checkVisibilityOnly = false ) const; + bool selectable( const EDA_ITEM* aItem, bool checkVisibilityOnly = false ) const; /** * Function select() @@ -186,7 +188,7 @@ private: * * @param aItem is an item to be selected. */ - void select( SCH_ITEM* aItem ); + void select( EDA_ITEM* aItem ); /** * Function unselect() @@ -194,7 +196,7 @@ private: * * @param aItem is an item to be unselected. */ - void unselect( SCH_ITEM* aItem ); + void unselect( EDA_ITEM* aItem ); /** * Function highlight() @@ -203,7 +205,7 @@ private: * @param aHighlightMode should be either SELECTED or BRIGHTENED * @param aGroup is the group to add the item to in the BRIGHTENED mode. */ - void highlight( SCH_ITEM* aItem, int aHighlightMode, SELECTION* aGroup = nullptr ); + void highlight( EDA_ITEM* aItem, int aHighlightMode, SELECTION* aGroup = nullptr ); /** * Function unhighlight() @@ -212,7 +214,7 @@ private: * @param aHighlightMode should be either SELECTED or BRIGHTENED * @param aGroup is the group to remove the item from. */ - void unhighlight( SCH_ITEM* aItem, int aHighlightMode, SELECTION* aGroup = nullptr ); + void unhighlight( EDA_ITEM* aItem, int aHighlightMode, SELECTION* aGroup = nullptr ); /** * Function selectionContains()