void ROUTER_TOOL::performDragging() { PCB_EDIT_FRAME* frame = getEditFrame<PCB_EDIT_FRAME>(); bool saveUndoBuffer = true; VIEW_CONTROLS* ctls = getViewControls(); bool dragStarted = m_router->StartDragging( m_startSnapPoint, m_startItem ); if( !dragStarted ) return; if( m_startItem && m_startItem->Net() >= 0 ) highlightNet( true, m_startItem->Net() ); ctls->ForceCursorPosition( false ); ctls->SetAutoPan( true ); while( OPT_TOOL_EVENT evt = Wait() ) { if( evt->IsCancel() || evt->IsActivate() ) break; else if( evt->Action() == TA_UNDO_REDO ) { saveUndoBuffer = false; break; } else if( evt->IsMotion() ) { updateEndItem( *evt ); m_router->Move( m_endSnapPoint, m_endItem ); } else if( evt->IsClick( BUT_LEFT ) ) { if( m_router->FixRoute( m_endSnapPoint, m_endItem ) ) break; } handleCommonEvents( *evt ); } if( m_router->RoutingInProgress() ) m_router->StopRouting(); if( saveUndoBuffer ) { // Save the recent changes in the undo buffer frame->SaveCopyInUndoList( m_router->GetUndoBuffer(), UR_UNSPECIFIED ); m_router->ClearUndoBuffer(); frame->OnModify(); } else { // It was interrupted by TA_UNDO_REDO event, so we have to sync the world now m_needsSync = true; } ctls->SetAutoPan( false ); ctls->ForceCursorPosition( false ); highlightNet( false ); }
void ROUTER_TOOL::performDragging( int aMode ) { VIEW_CONTROLS* ctls = getViewControls(); if( m_startItem && m_startItem->IsLocked() ) { KIDIALOG dlg( frame(), _( "The selected item is locked." ), _( "Confirmation" ), wxOK | wxCANCEL | wxICON_WARNING ); dlg.SetOKLabel( _( "Drag Anyway" ) ); dlg.DoNotShowCheckbox( __FILE__, __LINE__ ); if( dlg.ShowModal() == wxID_CANCEL ) return; } bool dragStarted = m_router->StartDragging( m_startSnapPoint, m_startItem, aMode ); if( !dragStarted ) return; if( m_startItem && m_startItem->Net() >= 0 ) highlightNet( true, m_startItem->Net() ); ctls->SetAutoPan( true ); m_gridHelper->SetAuxAxes( true, m_startSnapPoint, true ); frame()->UndoRedoBlock( true ); while( OPT_TOOL_EVENT evt = Wait() ) { ctls->ForceCursorPosition( false ); if( evt->IsMotion() ) { updateEndItem( *evt ); m_router->Move( m_endSnapPoint, m_endItem ); } else if( evt->IsClick( BUT_LEFT ) ) { if( m_router->FixRoute( m_endSnapPoint, m_endItem ) ) break; } else if( TOOL_EVT_UTILS::IsCancelInteractive( *evt ) || evt->IsUndoRedo() ) { break; } handleCommonEvents( *evt ); } if( m_router->RoutingInProgress() ) m_router->StopRouting(); m_startItem = nullptr; m_gridHelper->SetAuxAxes( false ); frame()->UndoRedoBlock( false ); ctls->SetAutoPan( false ); ctls->ForceCursorPosition( false ); highlightNet( false ); }
void ROUTER_TOOL::performDragging() { VIEW_CONTROLS* ctls = getViewControls(); if( m_startItem && m_startItem->IsLocked() ) { if( !IsOK( m_frame, _( "The item is locked. Do you want to continue?" ) ) ) return; } bool dragStarted = m_router->StartDragging( m_startSnapPoint, m_startItem ); if( !dragStarted ) return; if( m_startItem && m_startItem->Net() >= 0 ) highlightNet( true, m_startItem->Net() ); ctls->SetAutoPan( true ); m_frame->UndoRedoBlock( true ); while( OPT_TOOL_EVENT evt = Wait() ) { ctls->ForceCursorPosition( false ); if( evt->IsMotion() ) { updateEndItem( *evt ); m_router->Move( m_endSnapPoint, m_endItem ); } else if( evt->IsClick( BUT_LEFT ) ) { if( m_router->FixRoute( m_endSnapPoint, m_endItem ) ) break; } else if( evt->IsCancel() || evt->IsActivate() || evt->IsUndoRedo() ) break; handleCommonEvents( *evt ); } if( m_router->RoutingInProgress() ) m_router->StopRouting(); m_startItem = NULL; m_frame->UndoRedoBlock( false ); ctls->SetAutoPan( false ); ctls->ForceCursorPosition( false ); highlightNet( false ); }
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_startItem = m_router->GetWorld()->FindItemByParent( item ); if( m_startItem && m_startItem->IsLocked() ) { if( !IsOK( m_frame, _( "The item is locked. Do you want to continue?" ) ) ) return false; } VECTOR2I p0 = ctls->GetCursorPosition(); bool dragStarted = m_router->StartDragging( p0, m_startItem ); if( !dragStarted ) return 0; ctls->ForceCursorPosition( false ); ctls->SetAutoPan( true ); frame->UndoRedoBlock( true ); while( OPT_TOOL_EVENT evt = Wait() ) { if( evt->IsCancel() ) { break; } else if( evt->IsMotion() || evt->IsDrag( BUT_LEFT ) ) { updateEndItem( *evt ); m_router->Move( m_endSnapPoint, m_endItem ); } else if( evt->IsMouseUp( BUT_LEFT ) || evt->IsClick( BUT_LEFT ) ) { updateEndItem( *evt ); m_router->FixRoute( m_endSnapPoint, m_endItem ); break; } } if( m_router->RoutingInProgress() ) m_router->StopRouting(); ctls->SetAutoPan( false ); ctls->ShowCursor( false ); frame->UndoRedoBlock( false ); return 0; }
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 ); frame->UndoRedoBlock( 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( m_router->RoutingInProgress() ) m_router->StopRouting(); if( saveUndoBuffer ) { frame->SaveCopyInUndoList( m_router->GetUndoBuffer(), UR_UNSPECIFIED ); m_router->ClearUndoBuffer(); frame->OnModify(); } ctls->SetAutoPan( false ); ctls->ShowCursor( false ); frame->UndoRedoBlock( false ); return 0; }
int ROUTER_TOOL::mainLoop( PNS::ROUTER_MODE aMode ) { PCB_EDIT_FRAME* frame = getEditFrame<PCB_EDIT_FRAME>(); // Deselect all items m_toolMgr->RunAction( PCB_ACTIONS::selectionClear, true ); Activate(); m_router->SetMode( aMode ); VIEW_CONTROLS* ctls = getViewControls(); ctls->ShowCursor( true ); ctls->ForceCursorPosition( false ); m_startSnapPoint = ctls->GetCursorPosition(); std::unique_ptr<ROUTER_TOOL_MENU> ctxMenu( new ROUTER_TOOL_MENU( *frame, aMode ) ); SetContextMenu( ctxMenu.get() ); // Main loop: keep receiving events while( OPT_TOOL_EVENT evt = Wait() ) { if( TOOL_EVT_UTILS::IsCancelInteractive( *evt ) ) { break; // Finish } else if( evt->Action() == TA_UNDO_REDO_PRE ) { m_router->ClearWorld(); } else if( evt->Action() == TA_UNDO_REDO_POST || evt->Action() == TA_MODEL_CHANGE ) { m_router->SyncWorld(); } else if( evt->IsMotion() ) { updateStartItem( *evt ); } else if( evt->IsAction( &PCB_ACTIONS::dragFreeAngle ) ) { updateStartItem( *evt, true ); performDragging( PNS::DM_ANY | PNS::DM_FREE_ANGLE ); } else if( evt->IsAction( &PCB_ACTIONS::drag45Degree ) ) { updateStartItem( *evt, true ); performDragging( PNS::DM_ANY ); } else if( evt->IsAction( &PCB_ACTIONS::breakTrack ) ) { updateStartItem( *evt, true ); breakTrack( ); } else if( evt->IsClick( BUT_LEFT ) || evt->IsAction( &ACT_NewTrack ) ) { updateStartItem( *evt ); if( evt->Modifier( MD_CTRL ) ) performDragging( PNS::DM_ANY ); else performRouting(); } else if( evt->IsAction( &ACT_PlaceThroughVia ) ) { m_toolMgr->RunAction( PCB_ACTIONS::layerToggle, true ); } } frame->SetNoToolSelected(); SetContextMenu( nullptr ); // Store routing settings till the next invocation m_savedSettings = m_router->Settings(); m_savedSizes = m_router->Sizes(); return 0; }