Removed explicit calls to update ratsnest from EDIT_TOOL

This commit is contained in:
Maciej Suminski 2017-08-01 13:11:07 +02:00
parent 1f6854f2b8
commit 1ac34b44bf
4 changed files with 31 additions and 31 deletions

View File

@ -372,11 +372,7 @@ int EDIT_TOOL::Main( const TOOL_EVENT& aEvent )
// Drag items to the current cursor position
for( auto item : selection )
{
static_cast<BOARD_ITEM*>( item )->Move( movement + m_offset );
}
updateRatsnest( true );
}
else if( !m_dragging ) // Prepare to start dragging
{
@ -481,7 +477,6 @@ int EDIT_TOOL::Main( const TOOL_EVENT& aEvent )
{
// Update dragging offset (distance between cursor and the first dragged item)
m_offset = static_cast<BOARD_ITEM*>( selection.Front() )->GetPosition() - modPoint;
updateRatsnest( true );
}
}
@ -494,8 +489,6 @@ int EDIT_TOOL::Main( const TOOL_EVENT& aEvent )
}
} while( ( evt = Wait() ) ); //Should be assignment not equality test
getModel<BOARD>()->GetConnectivity()->ClearDynamicRatsnest();
controls->ForceCursorPosition( false );
controls->ShowCursor( false );
controls->SetSnapping( false );
@ -590,8 +583,6 @@ int EDIT_TOOL::Rotate( const TOOL_EVENT& aEvent )
if( !m_dragging )
m_commit->Push( _( "Rotate" ) );
else
updateRatsnest( true );
if( selection.IsHover() )
m_toolMgr->RunAction( PCB_ACTIONS::selectionClear, true );
@ -699,8 +690,6 @@ int EDIT_TOOL::Mirror( const TOOL_EVENT& aEvent )
if( !m_dragging )
m_commit->Push( _( "Mirror" ) );
else
updateRatsnest( true );
if( selection.IsHover() )
m_toolMgr->RunAction( PCB_ACTIONS::selectionClear, true );
@ -734,8 +723,6 @@ int EDIT_TOOL::Flip( const TOOL_EVENT& aEvent )
if( !m_dragging )
m_commit->Push( _( "Flip" ) );
else
updateRatsnest( true );
if( selection.IsHover() )
m_toolMgr->RunAction( PCB_ACTIONS::selectionClear, true );
@ -1144,19 +1131,6 @@ void EDIT_TOOL::setTransitions()
}
void EDIT_TOOL::updateRatsnest( bool aRedraw )
{
auto& selection = m_selectionTool->GetSelection();
auto connectivity = getModel<BOARD>()->GetConnectivity();
std::vector<BOARD_ITEM *> items;
for ( auto item : selection )
items.push_back ( static_cast<BOARD_ITEM *>( item ) );
connectivity->ComputeDynamicRatsnest( items );
}
wxPoint EDIT_TOOL::getModificationPoint( const SELECTION& aSelection )
{
if( aSelection.Size() == 1 )

View File

@ -145,11 +145,6 @@ private:
///> of edit reference point).
VECTOR2I m_cursor;
///> Updates ratsnest for selected items.
///> @param aRedraw says if selected items should be drawn using the simple mode (e.g. one line
///> per item).
void updateRatsnest( bool aRedraw );
///> Returns the right modification point (e.g. for rotation), depending on the number of
///> selected items.
wxPoint getModificationPoint( const SELECTION& aSelection );

View File

@ -1136,6 +1136,33 @@ int PCB_EDITOR_CONTROL::ShowLocalRatsnest( const TOOL_EVENT& aEvent )
int PCB_EDITOR_CONTROL::UpdateSelectionRatsnest( const TOOL_EVENT& aEvent )
{
auto selectionTool = m_toolMgr->GetTool<SELECTION_TOOL>();
auto& selection = selectionTool->GetSelection();
if( selection.Empty() )
{
getModel<BOARD>()->GetConnectivity()->ClearDynamicRatsnest();
}
else
{
auto connectivity = getModel<BOARD>()->GetConnectivity();
std::vector<BOARD_ITEM*> items;
items.reserve( selection.Size() );
for( auto item : selection )
items.push_back( static_cast<BOARD_ITEM*>( item ) );
connectivity->ComputeDynamicRatsnest( items );
}
return 0;
}
int PCB_EDITOR_CONTROL::HideSelectionRatsnest( const TOOL_EVENT& aEvent )
{
getModel<BOARD>()->GetConnectivity()->ClearDynamicRatsnest();
return 0;
}
@ -1171,6 +1198,7 @@ void PCB_EDITOR_CONTROL::setTransitions()
Go( &PCB_EDITOR_CONTROL::HighlightNetCursor, PCB_ACTIONS::highlightNetCursor.MakeEvent() );
Go( &PCB_EDITOR_CONTROL::ShowLocalRatsnest, PCB_ACTIONS::showLocalRatsnest.MakeEvent() );
Go( &PCB_EDITOR_CONTROL::UpdateSelectionRatsnest, PCB_ACTIONS::selectionModified.MakeEvent() );
Go( &PCB_EDITOR_CONTROL::HideSelectionRatsnest, SELECTION_TOOL::ClearedEvent );
}

View File

@ -105,6 +105,9 @@ public:
///> Updates ratsnest for selected items.
int UpdateSelectionRatsnest( const TOOL_EVENT& aEvent );
///> Hides ratsnest for selected items. Called when there are no items selected.
int HideSelectionRatsnest( const TOOL_EVENT& aEvent );
///> Shows local ratsnest of a component
int ShowLocalRatsnest( const TOOL_EVENT& aEvent );