router: invoke interactive drag when dragging traces/vias in edit tool (disabled by default)
This commit is contained in:
parent
a86fda1d37
commit
171d39c8d0
|
@ -1241,3 +1241,14 @@ void PNS_NODE::SetCollisionFilter( PNS_COLLISION_FILTER* aFilter )
|
|||
{
|
||||
m_collisionFilter = aFilter;
|
||||
}
|
||||
|
||||
PNS_ITEM *PNS_NODE::FindItemByParent ( const BOARD_CONNECTED_ITEM *aParent )
|
||||
{
|
||||
PNS_INDEX::NET_ITEMS_LIST* l_cur = m_index->GetItemsForNet( aParent->GetNetCode() );
|
||||
|
||||
BOOST_FOREACH( PNS_ITEM*item, *l_cur )
|
||||
if ( item->Parent() == aParent )
|
||||
return item;
|
||||
|
||||
return NULL;
|
||||
}
|
|
@ -373,6 +373,8 @@ public:
|
|||
int RemoveByMarker( int aMarker );
|
||||
void SetCollisionFilter( PNS_COLLISION_FILTER* aFilter );
|
||||
|
||||
PNS_ITEM *FindItemByParent ( const BOARD_CONNECTED_ITEM *aParent );
|
||||
|
||||
private:
|
||||
struct OBSTACLE_VISITOR;
|
||||
typedef boost::unordered_multimap<PNS_JOINT::HASH_TAG, PNS_JOINT> JOINT_MAP;
|
||||
|
|
|
@ -279,7 +279,7 @@ void ROUTER_TOOL::Reset( RESET_REASON aReason )
|
|||
Go( &ROUTER_TOOL::RouteDiffPair, COMMON_ACTIONS::routerActivateDiffPair.MakeEvent() );
|
||||
Go( &ROUTER_TOOL::DpDimensionsDialog, COMMON_ACTIONS::routerActivateDpDimensionsDialog.MakeEvent() );
|
||||
Go( &ROUTER_TOOL::SettingsDialog, COMMON_ACTIONS::routerActivateSettingsDialog.MakeEvent() );
|
||||
|
||||
Go( &ROUTER_TOOL::InlineDrag, COMMON_ACTIONS::routerInlineDrag.MakeEvent() );
|
||||
}
|
||||
|
||||
|
||||
|
@ -770,6 +770,62 @@ void ROUTER_TOOL::performDragging()
|
|||
|
||||
int ROUTER_TOOL::InlineDrag( const TOOL_EVENT& aEvent )
|
||||
{
|
||||
const BOARD_CONNECTED_ITEM *item = aEvent.Parameter<const BOARD_CONNECTED_ITEM*>();
|
||||
PCB_EDIT_FRAME* frame = getEditFrame<PCB_EDIT_FRAME>();
|
||||
VIEW_CONTROLS* ctls = getViewControls();
|
||||
|
||||
m_toolMgr->RunAction( COMMON_ACTIONS::selectionClear, true );
|
||||
|
||||
Activate();
|
||||
|
||||
m_router->SyncWorld();
|
||||
m_router->SetView( getView() );
|
||||
|
||||
m_startItem = m_router->GetWorld()->FindItemByParent( item );
|
||||
|
||||
VECTOR2I p0 = ctls->GetCursorPosition();
|
||||
|
||||
bool dragStarted = m_router->StartDragging( p0, m_startItem );
|
||||
|
||||
if( !dragStarted )
|
||||
return 0;
|
||||
|
||||
ctls->ForceCursorPosition( false );
|
||||
ctls->SetAutoPan( true );
|
||||
|
||||
bool saveUndoBuffer = true;
|
||||
|
||||
while( OPT_TOOL_EVENT evt = Wait() )
|
||||
{
|
||||
p0 = ctls->GetCursorPosition();
|
||||
|
||||
if( evt->IsCancel() )
|
||||
{
|
||||
saveUndoBuffer = false;
|
||||
break;
|
||||
}
|
||||
|
||||
else if( evt->IsMotion() || evt->IsDrag( BUT_LEFT ) )
|
||||
{
|
||||
m_router->Move( p0, NULL );
|
||||
}
|
||||
else if( evt->IsMouseUp( BUT_LEFT ) || evt->IsClick( BUT_LEFT ) )
|
||||
{
|
||||
saveUndoBuffer = m_router->FixRoute( p0, NULL );
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if(saveUndoBuffer)
|
||||
{
|
||||
frame->SaveCopyInUndoList( m_router->GetUndoBuffer(), UR_UNSPECIFIED );
|
||||
m_router->ClearUndoBuffer();
|
||||
frame->OnModify();
|
||||
}
|
||||
|
||||
ctls->SetAutoPan( false );
|
||||
ctls->ForceCursorPosition( false );
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -105,10 +105,12 @@ bool EDIT_TOOL::invokeInlineRouter()
|
|||
TRACK* track = uniqueSelected<TRACK>();
|
||||
VIA* via = uniqueSelected<VIA>();
|
||||
|
||||
if ( !GetSettings().Get("DragInvokesRouter", false ) )
|
||||
return false;
|
||||
|
||||
if( track || via )
|
||||
{
|
||||
//printf("Calling interactive drag\n");
|
||||
m_toolMgr->RunAction( COMMON_ACTIONS::routerInlineDrag, true );
|
||||
m_toolMgr->RunAction( COMMON_ACTIONS::routerInlineDrag, true, track ? track : via );
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -243,57 +245,60 @@ int EDIT_TOOL::Main( const TOOL_EVENT& aEvent )
|
|||
}
|
||||
else // Prepare to start dragging
|
||||
{
|
||||
m_selectionTool->SanitizeSelection();
|
||||
|
||||
if( selection.Empty() )
|
||||
break;
|
||||
|
||||
// deal with locked items (override lock or abort the operation)
|
||||
SELECTION_LOCK_FLAGS lockFlags = m_selectionTool->CheckLock();
|
||||
|
||||
if( lockFlags == SELECTION_LOCKED )
|
||||
break;
|
||||
else if( lockFlags == SELECTION_LOCK_OVERRIDE )
|
||||
lockOverride = true;
|
||||
|
||||
// Save items, so changes can be undone
|
||||
if( !isUndoInhibited() )
|
||||
if( !isDragAndDrop || !invokeInlineRouter() )
|
||||
{
|
||||
editFrame->OnModify();
|
||||
editFrame->SaveCopyInUndoList( selection.items, UR_CHANGED );
|
||||
m_selectionTool->SanitizeSelection();
|
||||
|
||||
if( selection.Empty() )
|
||||
break;
|
||||
|
||||
// deal with locked items (override lock or abort the operation)
|
||||
SELECTION_LOCK_FLAGS lockFlags = m_selectionTool->CheckLock();
|
||||
|
||||
if( lockFlags == SELECTION_LOCKED )
|
||||
break;
|
||||
else if( lockFlags == SELECTION_LOCK_OVERRIDE )
|
||||
lockOverride = true;
|
||||
|
||||
// Save items, so changes can be undone
|
||||
if( !isUndoInhibited() )
|
||||
{
|
||||
editFrame->OnModify();
|
||||
editFrame->SaveCopyInUndoList( selection.items, UR_CHANGED );
|
||||
}
|
||||
|
||||
VECTOR2I origin;
|
||||
|
||||
if( evt->IsDrag( BUT_LEFT ) )
|
||||
mousePos = evt->DragOrigin();
|
||||
|
||||
// origin = grid.Align ( evt->DragOrigin() );
|
||||
//else
|
||||
origin = grid.Align( mousePos );
|
||||
|
||||
if( selection.Size() == 1 )
|
||||
{
|
||||
// Set the current cursor position to the first dragged item origin, so the
|
||||
// movement vector could be computed later
|
||||
m_cursor = grid.BestDragOrigin( mousePos, selection.Item<BOARD_ITEM>( 0 ) );
|
||||
getViewControls()->ForceCursorPosition( true, m_cursor );
|
||||
grid.SetAuxAxes( true, m_cursor );
|
||||
|
||||
VECTOR2I o = VECTOR2I( selection.Item<BOARD_ITEM>( 0 )->GetPosition() );
|
||||
m_offset.x = o.x - m_cursor.x;
|
||||
m_offset.y = o.y - m_cursor.y;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_offset = static_cast<BOARD_ITEM*>( selection.items.GetPickedItem( 0 ) )->GetPosition() -
|
||||
wxPoint( origin.x, origin.y );
|
||||
getViewControls()->ForceCursorPosition( true, origin );
|
||||
}
|
||||
|
||||
controls->SetAutoPan( true );
|
||||
m_dragging = true;
|
||||
incUndoInhibit();
|
||||
}
|
||||
|
||||
VECTOR2I origin;
|
||||
|
||||
if( evt->IsDrag( BUT_LEFT ) )
|
||||
mousePos = evt->DragOrigin();
|
||||
|
||||
// origin = grid.Align ( evt->DragOrigin() );
|
||||
//else
|
||||
origin = grid.Align( mousePos );
|
||||
|
||||
if( selection.Size() == 1 )
|
||||
{
|
||||
// Set the current cursor position to the first dragged item origin, so the
|
||||
// movement vector could be computed later
|
||||
m_cursor = grid.BestDragOrigin( mousePos, selection.Item<BOARD_ITEM>( 0 ) );
|
||||
getViewControls()->ForceCursorPosition( true, m_cursor );
|
||||
grid.SetAuxAxes( true, m_cursor );
|
||||
|
||||
VECTOR2I o = VECTOR2I( selection.Item<BOARD_ITEM>( 0 )->GetPosition() );
|
||||
m_offset.x = o.x - m_cursor.x;
|
||||
m_offset.y = o.y - m_cursor.y;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_offset = static_cast<BOARD_ITEM*>( selection.items.GetPickedItem( 0 ) )->GetPosition() -
|
||||
wxPoint( origin.x, origin.y );
|
||||
getViewControls()->ForceCursorPosition( true, origin );
|
||||
}
|
||||
|
||||
controls->SetAutoPan( true );
|
||||
m_dragging = true;
|
||||
incUndoInhibit();
|
||||
}
|
||||
|
||||
selection.group->ViewUpdate( KIGFX::VIEW_ITEM::GEOMETRY );
|
||||
|
|
Loading…
Reference in New Issue